#include <IRremote.hpp>

const int receiverPin = 11;  // Pin connected to IR receiver
const int ledRedPin = 8;     // Pin connected to Red LED
const int ledWhitePin = 9;   // Pin connected to White LED

bool ledRedState = false;
bool ledWhiteState = false;

void setup() {
  pinMode(ledRedPin, OUTPUT);
  pinMode(ledWhitePin, OUTPUT);

  IrReceiver.begin(receiverPin, ENABLE_LED_FEEDBACK);  // Initialize the IR receiver
  Serial.begin(9600);  // Initialize serial communication for debugging
}

void loop() {
  if (IrReceiver.decode()) {  // Check if a signal is received
    unsigned long keyValue = IrReceiver.decodedIRData.command;  // Get the command from the IR signal
    Serial.println(keyValue, HEX);  // Print the value received for debugging

    switch (keyValue) {
      case 0x30:  // Code for button "1"
        ledRedState = !ledRedState;  // Toggle the red LED
        digitalWrite(ledRedPin, ledRedState);
        break;
      case 0x18:  // Code for button "2"
        ledWhiteState = !ledWhiteState;  // Toggle the white LED
        digitalWrite(ledWhitePin, ledWhiteState);
        break;
    }

    IrReceiver.resume();  // Prepare for the next value
  }
}