#include <IRremote.h>
const int RECV_PIN = 11; // Pin connected to IR receiver
IRrecv irrecv(RECV_PIN); // Create an instance of the IRrecv class
decode_results results; // Structure to hold decoded IR data
void setup() {
Serial.begin(9600); // Start serial communication for debugging
irrecv.enableIRIn(); // Start the receiver
Serial.println("IR Receiver ready to receive signals.");
}
void loop() {
// Check if a signal has been received
if (irrecv.decode(&results)) {
Serial.print("Received IR code: ");
Serial.println(results.value, HEX); // Print the received code in hexadecimal format
// Example action based on IR code (replace 0xFF629D with your remote's specific code)
if (results.value == 0xFF629D) { // Replace with a known button code
Serial.println("Button: UP");
// Perform an action, such as turning on an LED
} else if (results.value == 0xFF22DD) {
Serial.println("Button: DOWN");
// Another action for a different button
}
// Resume receiving the next signal
irrecv.resume();
}
}