// Define pin connections
const int irSensorPin = 8; // IR sensor output pin
const int buzzerPin = 9; // Buzzer pin
const int ledPin = 10; // LED pin
void setup() {
pinMode(irSensorPin, INPUT); // Set IR sensor pin as input
pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output
pinMode(ledPin, OUTPUT); // Set LED pin as output
[Link](9600);
// Initialize Serial Monitor for debugging
// put your setup code here, to run once:
void loop() {
int irValue = digitalRead(irSensorPin); // Read the IR sensor value
if (irValue = HIGH)
// Intruder detected
digitalWrite(buzzerPin, HIGH); // Turn on buzzer
digitalWrite(ledPin, HIGH); // Turn on LED
[Link]("Intruder detected!");// Debug message
delay(1000);
else
// No intruder
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
[Link]("No Intruder");// Turn off LED
delay(1000);
delay(1000); // Small delay to avoid rapid switching
// Turn off buzzer
// put your main code here, to run repeatedly: