#define IR_SENSOR 2
#define BUZZER 8
void setup() {
pinMode(IR_SENSOR, INPUT);
pinMode(BUZZER, OUTPUT);
Serial.begin(9600);
Serial.println("System Ready - Monitoring for Intrusion...");
}
void loop() {
int irState = digitalRead(IR_SENSOR);
if (irState == LOW) { // Object detected (typical IR sensor behavior)
digitalWrite(BUZZER, HIGH);
Serial.println("🚨 Intrusion Detected!");
} else {
digitalWrite(BUZZER, LOW);
Serial.println("Area Clear.");
}
delay(500); // Small delay to avoid flooding the serial monitor
}
To embed this project on your website, copy the following code and paste it into your website's HTML: