How to Make a Motion Sensor Alarm with Arduino for Under $20


Making a motion sensor alarm with Arduino is an easy and affordable way to add security to your home or office. With just a few components, you can build a fully-functional alarm system that will detect movement and sound an audible alert.

In this guide, I will walk through the entire process of assembling and programming a motion sensor alarm using an Arduino microcontroller board. The total cost for this project is under $20, making it very budget-friendly. No prior experience with Arduino or electronics is necessary to follow along.

Required Components

To build the motion sensor alarm, you will need the following components:

The total cost is less than $20! You may also need a 9V battery and power adapter for powering the Arduino.


To assemble the motion sensor alarm:

Here is a circuit diagram showing the connections:

How to Make a Motion Sensor Alarm with Arduino for Under

Be sure all components are securely inserted into the breadboard, with no loose wires.

Arduino Code

Next, you need to upload code to the Arduino to operate the alarm. I recommend the following sketch:

// Motion Sensor Alarm by

int buzzer = 13; // buzzer connected to pin 13
int sensor = 2; // motion sensor connected to pin 2

void setup() {
pinMode(buzzer, OUTPUT); // Set buzzer as an output
pinMode(sensor, INPUT); // Set sensor as an input

void loop() {
if (digitalRead(sensor) == HIGH) { // If motion is detected
digitalWrite(buzzer, HIGH); // Sound alarm
else {
digitalWrite(buzzer, LOW); // No motion = no alarm

This code initializes the buzzer and sensor pins, then continuously checks the sensor input. If motion is detected, it sounds the buzzer by setting it HIGH.

Upload this sketch to your Arduino board and open the serial monitor. Your motion alarm is now ready for testing!

Testing and Use

To test the alarm, simply walk in front of the PIR sensor. You should hear the buzzer sound each time motion is detected.

Your DIY motion sensor alarm provides an affordable way to monitor rooms, catch intruders, or detect customers entering a store. And it's a fun, educational Arduino project!


In this guide, I built a motion sensor alarm with an Arduino Uno, PIR sensor, buzzer, and breadboard for under $20.

Key steps included:

With just basic components, you can construct your own security device to detect motion. Try expanding on this project by adding a camera, LCD display, or alarm notifications over WiFi. The possibilities are endless!

Let me know if you have any other questions in the comments. And be sure to subscribe for more DIY Arduino projects soon.