#include <IRremote.h>
int RECV_PIN = 7;
int LED13 = 13;
int LED12 = 12;
int LED11 = 11;
int LED10 = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
pinMode(LED13, OUTPUT);
pinMode(LED12, OUTPUT);
pinMode(LED11, OUTPUT);
pinMode(LED10, OUTPUT);
pinMode(RECV_PIN, INPUT);
irrecv.enableIRIn();
Serial.begin(9600);
Serial.println("IR Remote Control");
}
int flag = 0;
void loop() {
// put your main code here, to run repeatedly:
if (irrecv.decode(&results)){
Serial.println(results.value,HEX);
irrecv.resume();
if (results.value == 0xFF0CF3){
digitalWrite(LED13,HIGH);
flag = 1;
Serial.println("LAMP1 = ON");
}if (results.value == 0xFF18E7){
digitalWrite(LED13, LOW);
flag = 0;
Serial.println("LAMP1 = OFF");
}if (results.value == 0xFF5EA1){
digitalWrite(LED12, HIGH);
flag = 1;
Serial.println("FAN1 = ON");
}if (results.value == 0xFF08F7){
digitalWrite(LED12, LOW);
flag = 0;
Serial.println("FAN1");
}if (results.value == 0xFF1CE3){
if (flag == 0){
digitalWrite(LED11, HIGH);
flag = 1;
Serial.println("DOOR = OPEN");
}else {
if (flag == 1){
digitalWrite(LED11, LOW);
flag = 0;
Serial.println("DOOR = LOCK");
}
}
}if (results.value == 0xFF42BD){
if (flag == 0){
digitalWrite(LED10, HIGH);
flag = 1;
Serial.println("PUMP = ON");
}else {
if (flag == 1){
digitalWrite(LED10, LOW);
flag = 0;
Serial.println("PUMP = OFF");
}
}
}
}
}