#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
|