#include <IRremote.h>
const int IR_PIN =12; // Pin to which the IR sensor is connected
const int LED_PIN = 4; // Pin to which the LED is connected
IRrecv irReceiver(IR_PIN);
decode_results irResults;
const unsigned long ON_CODE = 0xFFFFFFFF; // HEX code for turning the LED on
const unsigned long OFF_CODE = 0x83D6D202; // HEX code for turning the LED off
bool isLedOn = false;
void setup() {
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
irReceiver.enableIRIn();
}
void loop() {
if (irReceiver.decode(&irResults)) {
// Print the received code to the serial monitor
Serial.println(irResults.value, HEX);
if (irResults.value == ON_CODE) {
digitalWrite(LED_PIN, HIGH);
isLedOn = true;
} else if (irResults.value == OFF_CODE) {
digitalWrite(LED_PIN, LOW);
isLedOn = false;
}
irReceiver.resume(); // Receive the next value
}
}