#include<LiquidCrystal_I2C.h>
#include<Wire.h>
#include <IRremote.h>
//
const int RECV_PIN = 2;
const int NUM_OF_BUTS = 21;
long BUTTON_CODES[NUM_OF_BUTS] = {
16729530,
16730040,
16729275,
16728255,
16729020,
16713720,
16717290,
16714230,
16717545,
16718310,
16715250,
16714995,
16718055,
16735905,
16713975,
16719075,
16734885,
16728765,
16732845,
16730805
};
String BUTTON_NAMES[NUM_OF_BUTS] = {
"POWER","MENU","Test","VOL+","BACK",
"PREV/LEFT","PAUSE/MUTE","NEXT/RIGTH",
"0","VOL-","CH","1","2","3","4","5","6","7","8","9"
};
int findButton(long val){
for(int i = 0; i < NUM_OF_BUTS; i++){
if(val == BUTTON_CODES[i]){
return i;
}
}
return val;
}
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
//Serial.println(results.value, HEX);
int button_id = findButton(results.value);
// Serial.println(results);
if (button_id <0) {
Serial.println("Unknown button is pressed!");
} else {
Serial.print("Button ");
Serial.print(BUTTON_NAMES[button_id]);
Serial.println(" is pressed!");
}
irrecv.resume(); // Receive the next value
}
}