How to Make a Motion Sensor Alarm with Arduino for Under $20
Introduction
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:
-
Arduino Uno board - The brains of the alarm that processes the sensor input and controls the outputs. Can be purchased for around $10.
-
Passive infrared (PIR) motion sensor - Detects motion in its field of view by sensing infrared radiation. Around $3.
-
Buzzer - Sounds an audible alarm when motion is detected. About $1.
-
Breadboard - Used to easily connect components. Around $5.
-
Jumper wires - For making connections between components. A few dollars.
The total cost is less than $20! You may also need a 9V battery and power adapter for powering the Arduino.
Assembly
To assemble the motion sensor alarm:
-
Connect the PIR motion sensor, buzzer, and Arduino to the breadboard using jumper wires.
-
The PIR sensor has 3 pins - power, ground, and output. Connect power to 5V pin on Arduino, ground to ground, and output to digital pin 2.
-
For the buzzer, connect positive leg to pin 13 on Arduino, and negative leg to ground.
Here is a circuit diagram showing the connections:
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 Makerguides.com
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.
-
Try adjusting the sensitivity and delay of the sensor to minimize false alarms.
-
Position the sensor to cover entrances or valuable areas.
-
Power the Arduino with a battery pack for true portability.
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!
Summary
In this guide, I built a motion sensor alarm with an Arduino Uno, PIR sensor, buzzer, and breadboard for under $20.
Key steps included:
-
Assembling the circuit on a breadboard.
-
Uploading the Arduino motion sensing sketch.
-
Testing the alarm and adjusting as needed.
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.