找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3404|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

Arduino實現(xiàn)電視盒子的紅外遙控

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:162514 發(fā)表于 2020-12-25 14:43 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
#include <Keypad.h>
#include<IRremote.h>
IRsend irsend;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {11,10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5,4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad keypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  Serial.begin(9600);

}

void loop(){
  char key = keypad.getKey();

  if(key){
    Serial.println(key);
  }
  keypad.getState();//鍵盤字符串實現(xiàn)

    if( key==  '#'){



          irsend.sendNEC(0x807F3BC4,32);}

   if(key==  '1') {

          irsend.sendNEC(0x807F53AC,32);  }

   if(key==  'A'){

          irsend.sendNEC(0x807F738C ,32);  }

    if(key==  '2'){

          irsend.sendNEC(0x807F4BB4,32);  }


    if(key==  '3'){  

          irsend.sendNEC(0x807F9966,32);}  

    if(key=='4'){  

          irsend.sendNEC(0x807F837C,32); }

     if(key=='D'){  

          irsend.sendNEC(0x807F11EE,32); }   
     if(key=='B'){  

          irsend.sendNEC(0x807FA956,32); }
     if(key=='C'){  

          irsend.sendNEC(0x807FA35C,32); }

      if(key=='5'){  

          irsend.sendNEC(0x807F49B6,32); }     

}
//發(fā)射管帶330歐接3



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表