#include <IRremote.h>
#include <LiquidCrystal_I2C.h>
int ir_pin_receiver = 2;
int button_value = 0;
IRrecv receiver(ir_pin_receiver);
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
// put your setup code here, to run once:
receiver.enableIRIn();
lcd.init();
lcd.backlight();
Serial.begin(9600);
lcd.begin(20, 4);
lcd.print("IR sensor & Remote");
}
void loop() {
// put your main code here, to run repeatedly:
if (receiver.decode()) {
translateIR();
receiver.resume();
}
}
int translateIR()
{
button_value = receiver.decodedIRData.command;
Serial.println("button_value: ");
Serial.println(button_value);
lcd.clear();
lcd.print("Button Press: ");
if (button_value = 162) {
lcd.println("POWER");
}
else if (button_value = 226) {
Serial.println("Menu");
}
else if (button_value = 34) {
Serial.println("TEST");
}
else if (button_value = 48) {
Serial.println("ONE");
}
else if (button_value = 2) {
lcd.println("PLUS");
}
else if (button_value = 194) {
Serial.println("BACK");
}
else if (button_value = 224) {
Serial.println("PREVIOUS");
}
else if (button_value = 168) {
Serial.println("PLAY");
}
else if (button_value = 104) {
Serial.println("ZERO");
}
else if (button_value = 152) {
Serial.println("MINUS");
}
else if (button_value = 176) {
Serial.println("C");
}
else if (button_value = 24) {
lcd.println("TWO");
}
else if (button_value = 122) {
Serial.println("THREE");
}
else if (button_value = 16) {
Serial.println("FOUR");
}
else if (button_value = 56) {
Serial.println("FIVE");
}
else if (button_value = 90) {
Serial.println("SIX");
}
else if (button_value = 66) {
Serial.println("SEVEN");
}
else if (button_value = 74) {
Serial.println("EIGHT");
}
else {
Serial.println("NINE");
}
}