A PIR sensor watches your door. The moment someone walks in, a loud buzzer triggers — your first home security system.
PIR (Passive Infrared) sensors detect changes in infrared radiation caused by warm bodies moving through their field of view. They output a simple HIGH/LOW digital signal — easy to wire and read.
What you'll learn: PIR sensor usage, digital input reading, buzzer alarm, and LED warning indicators.
Estimated time: 25–35 minutes. Difficulty: ⭐ Beginner-friendly.
| Component | Specification | Qty | Notes |
|---|---|---|---|
| Arduino Uno R3 | 5V | 1 | |
| PIR Sensor (HC-SR501) | 5–20V, adjustable | 1 | Most common PIR sensor |
| Piezo Buzzer | Passive 5V | 1 | |
| Red LED | 5mm | 1 | Alarm indicator |
| Resistor | 220Ω | 1 | For LED |
| Breadboard + Wires | Standard | 1 |
// Motion Door Alarm — Volt X
const int PIR = 2;
const int BUZZER = 8;
const int LED = 9;
void setup() {
pinMode(PIR, INPUT);
pinMode(BUZZER, OUTPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600);
Serial.println("Calibrating PIR... wait 30s");
delay(30000);
Serial.println("Ready! Watching for motion...");
}
void loop() {
if (digitalRead(PIR) == HIGH) {
Serial.println("MOTION DETECTED!");
digitalWrite(LED, HIGH);
tone(BUZZER, 2000, 200);
delay(300);
tone(BUZZER, 1500, 200);
delay(300);
tone(BUZZER, 2000, 200);
delay(300);
digitalWrite(LED, LOW);
noTone(BUZZER);
delay(1000);
}
}Sign in to leave a review
No reviews yet. Be the first to share your experience!