找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2626|回复: 0
收起左侧

Arduino实现电视盒子的红外遥控

[复制链接]
ID:162514 发表于 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();//键盘字符串实现

    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); }     

}
//发射管带330欧接3



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表