Build a simple intruder alarm in under an hour: a PIR sensor watches for movement and instantly sounds a buzzer and flashes a warning LED.
What you’ll build
The PIR sensor detects the infrared signature of a moving person up to several metres away. The Arduino Nano watches its output pin and, on any motion, drives an active buzzer and a red LED for a few seconds — the core of every burglar alarm.
Components you’ll need
| Component | Qty | Price |
|---|---|---|
| Arduino Nano ATmega328P Compatible Board | 1 | ₹149 |
| PIR Motion Sensor | 1 | ₹129 |
| Active Buzzer | 1 | ₹299 |
| 5mm Red LED | 1 | ₹149 |
| 220 Ohm 1/4W | 1 | ₹49 |
| 400 Point Breadboard | 1 | ₹299 |
| Jumper Wires MM | 1 | ₹299 |
| Total | ₹1,373 |
Step-by-step guide
- Mount the PIR sensor on the breadboard: VCC to 5V, GND to GND, OUT to pin D2.
- Connect the active buzzer: positive leg to D8, negative leg to GND.
- Wire the red LED to D9 through the 220Ω resistor (long leg to resistor, short leg to GND).
- Keep the PIR’s two orange trim pots at minimum to start — one sets sensitivity, the other sets how long OUT stays high.
- Upload the sketch, then stay still for ~40 seconds while the PIR calibrates itself.
- Wave your hand in front of the sensor: the buzzer should beep and the LED flash for three seconds.
The code
The sketch waits for the PIR to pull D2 high, then runs the alarm pattern. A calibration delay on boot prevents false alarms.
const int pir=2, buzzer=8, led=9;
void setup(){
pinMode(pir,INPUT); pinMode(buzzer,OUTPUT); pinMode(led,OUTPUT);
delay(40000); // PIR warm-up / self-calibration
}
void loop(){
if(digitalRead(pir)==HIGH){
for(int i=0;i<6;i++){ // 3-second alarm burst
digitalWrite(buzzer,HIGH); digitalWrite(led,HIGH); delay(250);
digitalWrite(buzzer,LOW); digitalWrite(led,LOW); delay(250);
}
}
}Build this project
Add all 7 required components to your cart in one click — total ₹1,373.
Add all components to cart