#include <IRremote.h>
IRrecv irrecv (2); // Sensor IR terhubung pin 2
decode_results results;
bool status = LOW;
int tombol;
int led1 = 7;
int led2 = 5;
int led3 = 6;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // start receiver remote
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop()
{
if (irrecv.decode())
{
tombol = irrecv.decodedIRData.command;
Serial.println(tombol);
if (tombol == 48)
{
Serial.println("Lampu 1");
status = !status;
digitalWrite(led1, status);
}
if(tombol == 24)
{
Serial.println("Lampu 2");
status = !status;
digitalWrite(led2, status);
}
if (tombol ==122)
{
Serial.println("Lampu 3");
status = !status;
digitalWrite(led3, status);
}
irrecv.resume();
}
}