PIR — Intruder Alarm
Motion + armed switch = loud alarm. Disarm first.
PIR
Buzzer
State machine
Security
What you will learn
- How a state machine works: armed vs triggered are two different states
- How to use millis() to track time without using delay() (so the code is responsive)
- How to combine multiple inputs (arm switch + motion sensor) safely
What you will need
| Component |
|---|
| 1× Arduino Uno R3 |
| 1× PIR motion sensor |
| 1× slide switch (arm/disarm) |
| 1× 220Ω resistor |
| 1× red LED |
| 1× buzzer |
Step by step
Take it further
- Add a "quiet armed" mode — armed with a green LED, no alarm (use a second switch).
- Log every alarm trigger to the Serial Monitor with a millis() timestamp.
- Add a third output: a second buzzer that pulses at 2Hz (low-battery warning style) when armed but the PIR has not fired for 1 hour (time to test the system).
Practise it before you build it
Wire this circuit in the ThinkEdge Learn simulator first. The simulator runs a real Arduino sketch against a modified-nodal-analysis solver, so the LED on screen actually lights when the current is right — no hardware, no burnt components, and a class can try it in a browser.
Related projects
PIR — Smart Doorbell / Welcome LightA guest walks up to the door — chime + welcome LED
Arduino — PIR Motion Burglar AlarmDetect motion with the PIR sensor and sound the buzzer
Police SirenAlternating red + blue LEDs with a wailing 600–1500 Hz buzzer
Ultrasonic — Reverse Parking SensorBeep faster as you get closer
DHT11 — Temperature AlarmToo hot, too cold, or just right
Ultrasonic — Pitch by DistanceCloser = higher pitch
Guides that use this project
5 guides on the site build this project as part of a longer explanation. The guide says why the circuit works; this page says how to wire it.
ESP32 IoT Projects: From a Single Sensor to a Live DashboardFive ESP32 IoT projects that teach sensors, MQTT publishing, deep sleep and reconnection, each staged so the logic runs in a browser simulator first.
LoRa and LoRaWAN: The Physics of Long Range, Low Power RadioLoRa is the radio, LoRaWAN is the network. Real link budgets, airtimes, the Indian 865 to 867 MHz band and the sensors you can send over it.
Mesh Networking: How Nodes Relay Data for Each OtherA mesh network lets nodes relay data for each other. How flooding and hop limits work, what mesh costs in latency, and when a simple star is better.
Security Camera: From Light on a Sensor to a Stream You Can StoreHow a security camera turns light into a compressed video stream, what 1080p really costs in storage, and how to build a motion-triggered one.
Drone Defence and Interceptor DronesHow drone defence works: why interceptors are cheaper than missiles, how the physics of the engagement works, and why airports are hardest to defend.
Where this project sits
It is also part of these lists, which is how a class usually finds it.
Arduino LED projects for beginners36 projects in this list
Arduino PIR motion sensor projects4 projects in this list
Arduino buzzer and tone projects19 projects in this list
Try the full simulator with your class
103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. One licence covers a whole school.