#include <IRremote.h>
#include <LiquidCrystal.h>
#define PIN_RECEIVER 2 // Signal Pin of IR receiver
IRrecv receiver(PIN_RECEIVER);
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void setup()
{
lcd.begin(16, 2);
lcd.print("<press a button>");
receiver.enableIRIn(); // Start the receiver
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
}
void loop()
{
// Checks received an IR signal
if (receiver.decode()) {
translateIR();
receiver.resume(); // Receive the next value
}
}
void lcdPrint(char* text)
{
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(text);
}
void translateIR()
{
// Takes command based on IR code received
switch (receiver.decodedIRData.command) {
// 1
case 48:
digitalWrite(5, HIGH);
delay(200);
digitalWrite(5, LOW);
delay(200);
digitalWrite(5, HIGH);
delay(200);
digitalWrite(5, LOW);
delay(200);
digitalWrite(5, HIGH);
delay(200);
digitalWrite(5, LOW);
delay(200);
digitalWrite(5, HIGH);
delay(200);
digitalWrite(5, LOW);
delay(200);
digitalWrite(5, HIGH);
delay(200);
digitalWrite(5, LOW);
delay(200);
break;
// 4
case 16:
lcdPrint("Hello World");
break;
// 6
case 90:
digitalWrite(4, HIGH);
delay(2000);
digitalWrite(4, LOW);
break;
default:
lcd.clear();
}
}