Whether you want to deter intruders or just get notified when someone enters a room, a motion sensor alarm is a useful home security project. With an Arduino microcontroller, a passive infrared (PIR) motion sensor, and a few other components, you can build your own alarm that detects movement and sounds an audible warning. Best of all, it requires minimal soldering and can be assembled in under 10 minutes.
What You'll Need
To build the motion sensor alarm, you'll need the following parts:
-
Arduino Uno - The brain of the alarm that processes input from the sensor and controls the output. The Arduino Uno is inexpensive but powerful.
-
HC-SR501 PIR motion sensor - This passive infrared sensor detects movement using infrared energy. It has adjustable sensitivity and delay settings.
-
Buzzer - An audible alarm that will sound when motion is detected. Any small buzzer will work.
-
Breadboard - A solderless breadboard makes it easy to prototype circuits without soldering.
-
Jumper wires - Used to connect the components to the breadboard and Arduino.
-
9V battery - Powers the Arduino. You can also use a 9V wall adapter.
-
9V battery clip - Connects the 9V battery to the Arduino's power rails.
Optional components include an LED to visually indicate motion detection and a switch to arm/disarm the alarm.
Circuit Design
The circuit for the motion sensor alarm only requires connecting four components:
-
The PIR sensor's output pin connects to Arduino pin 2.
-
The buzzer's positive lead connects to Arduino pin 3. The negative lead connects to ground.
-
The 9V battery powers the Arduino through the Vin pin.
-
Arduino and component grounds are connected.
The PIR sensor acts as an input, while the buzzer is an output. No coding or soldering is required other than plugging components into the breadboard!
Adjusting Settings
The PIR sensor has two adjustable controls:
-
The sensitivity potentiometer adjusts the range and sensitivity to motion detection. Turn clockwise to increase sensitivity.
-
The time delay adjustment sets how long the alarm sounds after detecting motion. Turn counterclockwise for a shorter delay.
For most applications, medium sensitivity and a 1-second delay will suffice. Test with different settings to fit your needs.
Uploading the Code
With the circuit complete, upload this simple Arduino sketch:
```cpp
const int pirPin = 2; // PIR Out pin
const int buzzer = 3; // Buzzer pin
void setup() {
pinMode(pirPin, INPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
if (digitalRead(pirPin) == HIGH) {
digitalWrite(buzzer, HIGH); // Sound alarm
delay(1000); // Delay 1 second
digitalWrite(buzzer, LOW); // Stop alarm
}
}
```
This initializes the pins, reads the PIR sensor pin, and triggers the buzzer for 1 second when motion is detected. Adjust the delay as needed.
Testing and Usage
Once programmed, power up the Arduino and move around in front of the PIR sensor. The buzzer should sound each time you are detected!
Position the sensor facing a door or area you want to monitor. Adjust the sensitivity and delay as needed to avoid false alarms.
The alarm will sound continuously for 1 second whenever motion is detected. To disable it, simply unplug the battery or flip the power switch.
And that's it! With just a few components and no soldering, you now have a working motion sensor alarm for your home security.
Going Further
To take this project further:
-
Add an LED that lights up when motion is detected.
-
Install a power switch to easily arm and disarm the alarm.
-
Use a relay to connect the alarm to larger devices like lights or alarms.
-
Mount components in an enclosure to create a self-contained alarm unit.
-
Add WiFi connectivity with an ESP8266 to get mobile alerts.
-
Create multiple networked units to monitor large areas.
With the power of Arduino, there are many possibilities for customizing and enhancing this motion sensing alarm to fit your needs!