#include <IRremote.h>
// Define pin connections
const int IR_RECEIVE_PIN = 2; // IR Receiver Output to Digital Pin 2
const int STATUS_LED_PIN = 8; // Status LED to Digital Pin 8
const int DETECTION_LED_PIN = 9; // Detection LED to Digital Pin 9
const int BUZZER_PIN = 10; // Buzzer to Digital Pin 10
IRrecv irrecv(IR_RECEIVE_PIN); // Create IR Receiver object
decode_results results; // Variable to store the results
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Initialize pin modes
pinMode(STATUS_LED_PIN, OUTPUT);
pinMode(DETECTION_LED_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
// Turn on the status LED to indicate the system is active
digitalWrite(STATUS_LED_PIN, HIGH);
// Start the IR receiver
irrecv.enableIRIn();
}
void loop() {
// Check if an IR signal has been received
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX); // Print the received value for debugging
// Example: Check if a specific button on the remote was pressed
// Replace 0xFFA25D with the actual code from your remote
if (results.value == 0xFFA25D) { // Example code for a specific button
// Turn on detection LED
digitalWrite(DETECTION_LED_PIN, HIGH);
// Activate buzzer
digitalWrite(BUZZER_PIN, HIGH);
// Keep the alert active for a duration
delay(500);
// Deactivate buzzer
digitalWrite(BUZZER_PIN, LOW);
// Turn off detection LED
digitalWrite(DETECTION_LED_PIN, LOW);
}
// Resume receiving the next value
irrecv.resume();
}
}