0% found this document useful (0 votes)
5 views2 pages

IR Sensor Intruder Alarm Code

Uploaded by

m78227771
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

IR Sensor Intruder Alarm Code

Uploaded by

m78227771
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// 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:

You might also like