#include <IRremote.h>
#define PIN_RECEIVER 2
IRrecv receiver(PIN_RECEIVER);
int led = 3;
int code;
void setup() {
// put your setup code here, to run once:
receiver.enableIRIn();
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (receiver.decode()) {
translateIR();
receiver.resume(); // Receive the next value
}
}
void translateIR() {
// Takes command based on IR code received
switch (receiver.decodedIRData.command) {
case 104: // Assuming 162 is the command code for turning on the LED
code = 1;
break;
default:
// Optionally handle other commands or do nothing
if (code == 1){
digitalWrite(led, HIGH);
}
break;
}
}