#include <IRremote.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
int RECV_PIN = 2;
int LCD_PIN = 3;
int SERV_PIN = 9;
LiquidCrystal_I2C lcd(0x27,16,2);
IRrecv receiver(RECV_PIN);
decode_results results;
unsigned long key_value = 0;
Servo myservo;
int pos = 0;
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
receiver.enableIRIn();
receiver.blink13(true);
myservo.attach(SERV_PIN);
myservo.write(pos);
}
void loop() {
// put your main code here, to run repeatedly:
if(receiver.decode()){
if (results.value == 0xFFFFFFFF) { // if the value is equal to 0xFFFFFFFF
results.value = key_value; // set the value to the key value
}
lcd.clear();
switch (results.value) { // compare the value to the following cases
case 0xFD00FF: // if the value is equal to 0xFD00FF
lcd.print("POWER"); // print "POWER" in the Serial Monitor
break;
case 0xFD807F:
lcd.print("VOL+");
break;
case 0xFD40BF:
lcd.print("FUNC/STOP");
break;
case 0xFD20DF:
lcd.print("|<<");
break;
case 0xFDA05F:
lcd.print(">||");
break ;
case 0xFD609F:
lcd.print(">>|");
break ;
case 0xFD10EF:
lcd.print("DOWN");
break ;
case 0xFD906F:
lcd.print("VOL-");
break ;
case 0xFD50AF:
lcd.print("UP");
break ;
case 0xFD30CF:
pos=0;
lcd.print("0");
break ;
case 0xFDB04F:
lcd.print("EQ");
break ;
case 0xFD708F:
lcd.print("ST/REPT");
break ;
case 0xFD08F7:
pos+=10;
lcd.print("1");
break ;
case 0xFD8877:
pos+=20;
lcd.print("2");
break ;
case 0xFD48B7:
pos+=30;
lcd.print("3");
break ;
case 0xFD28D7:
pos+=40;
lcd.print("4");
break ;
case 0xFDA857:
pos+=50;
lcd.print("5");
break ;
case 0xFD6897:
lcd.print("6");
break ;
case 0xFD18E7:
lcd.print("7");
break ;
case 0xFD9867:
lcd.print("8");
break ;
case 0xFD58A7:
lcd.print("9");
break ;
}
myservo.write(pos);
key_value = results.value; // store the value as key_value
receiver.resume(); // reset the receiver for the next code
}
delay(100);
}