How to Build a Motion Detector Alarm Circuit
In this project, we will go over how to build a motion detector alarm circuit.
This is an alarm circuit which will go off when any motion or movement is detected. Once it detects this motion, the circuit will trigger an alarm buzzer to sound which will remain on until the power is disconnected from the circuit. This alarm circuit's most common use is to detect a person moving through an area where the motion detector can sense.
Before this, we built a simpler motion detector circuit that turned on an LED once motion was detected. But 1 or 2 seconds after, the LED would go off. The difference between that circuit and this one which we're now building is that an alarm must stay on once it is activated until it is manually turned off such as by shutting off all power. If an alarm just went off once and stopped, it wouldn't be very much of an alarm. Once motion is detected with this circuit, it will turn on the buzzer, which will buzz until the circuit is manually disconnected. This is similar to an alarm only shutting off when a homeowner enters in the password to turn it off.
In our circuit, when the motion detector circuit picks up movement, a buzzer will turn on and remain on until
the power feeding it is disconnected.
Parts Needed for Motion Detector Alarm Circuit
- PIR motion sensor
- 1.5-3V Buzzer
We will use a low-voltage buzzer for this circuit, one that only needs 1.5V to 3V to operate. However, you can use any buzzer that can operate at 5V of power or less. If you only have buzzers that need more voltage, then you'll have to power the buzzer with an external power source. Instead of connecting the anode of the buzzer to the 5V terminal of the arduino, you would connect it to an external voltage source, giving it the necessary voltage the buzzer would need.
The main electronic component we will use that allows us to pick up this detection is the PIR motion sensor. The PIR motion sensor is a sensor which detects movement through picking up infrared waves. Being that a person emits infrared radiation, the detector is able to detect this radiation and react, according to the how the circuit is designed to react. Being that people naturally give off infrared radiation (heat energy), because of our generated body heat, the sensor can easily detect people walking and moving through a vicinity within the sensor's range. The sensor can also pick up the movement of inanimate objects as well, such a rolling ball, because as these objects move, friction acts on them, generating heat. This heat emits infrared radiation, which the PIR sensors may be able to detect if enough radiation is given off.
The motion sensor has a sensitivity range up to 20 feet (6 meters) and a 110° x 70° detection range, making it a wide lens detection sensor. This means it can measure 110° vertically (from top to bottom) and 70° horizontally (from left to right). The best way to check its sensitivity is when the circuit is built, try moving around through all of its angles. See at which angles it can detect your movement and at which angles it is not able to detect your movement, meaning you're out of its angle scope. A lot of it is trial and error and experimenting. Once you know where it can and cannot detect, you can place it in an optimal place where it can detect in areas where you want it to.
The PIR motion sensor is a 3-pin device. Below is the pinout of this device:
Pin 1 is the pin which receives the positive DC voltage. The PIR motion sensor needs between 5V-9VDC of power for operation.
Pin 2 is the output pin of the PIR module. This is where the output of the PIR will leave from. When motion is detected by the PIR, its output will go high to 3V. When no motion is detected, its output low and it gives off practically no voltage. When high you can see then how it can power a load, such as a buzzer. This way we can know when it has detected motion or not.
Pin 3 is the negative DC voltage or ground pin of the device. We connect the negative terminal of the power source to this pin, for a return path.
In our circuit, we will connect the PIR motion sensor to the power terminals of the arduino and the output pin to digital pin D3 of the arduino. Pin 1 of the PIR sensor connects to the 5V terminal of the arduino. Pin 3 connects to the ground (GND) terminal of the arduino. These pins are how the motion sensor receives the power it needs to operate.
Pin 2, the output pin of the PIR sensor, connects to digital pin, D2, of the arduino. And it is through pin 3 that the arduino receives output from the motion sensor. When the motion detector does not detect any motion, the output is LOW and the arduino receives no voltage signal. When the sensor detects motion, the output is HIGH and the arduino receives a voltage signal, which can then trigger another device to turn on, such as a buzzer we will use for this circuit.
The buzzer we will power connects pin 12 and ground of the board. The anode connects to pin 12 and the cathode connects to ground.
Motion Detector Alarm Circuit Schematic
The circuit, along with its schematic diagram that we will build, are shown below:
The schematic diagram of this circuit is:
Again, once motion is detected, the PIR motion sensor will send a voltage signal to pin D2 of the arduino. When the arduino board detects this signal, it will turn on the buzzer connected to pin D12 on the arduino.
This is done in software. We will write a program that will turn on the buzzer once a HIGH voltage signal is received at pin D2 from the PIR motion
Code for Motion Detector Alarm Circuit
The following code, or sketch, will turn on the buzzer on pin 12 when the sensor detects motion:
const int buzzerPin= 12;
const int inputPin= 2;
int value= digitalRead(inputPin);
if (value == HIGH)
The first block of code chooses the pin for the buzzer, which is pin 12. The second line chooses the pin for the input pin, which represents the PIR sensor, pin 2.
The second block of code declares the buzzer as output and the output of the PIR motion sensor as input.
The third block of code reads the input value and assigns it to the integer named value. It reads whether the input pin is HIGH or LOW. If it is HIGH, then the motion sensor has detected motion. If it is low, the sensor has not detected any motion. If the value is HIGH, it turns the buzzer on, signaling that motion has, in fact, been detected. Once motion has been detected, the buzzer sounds and stays on. It doesn't shut off. This simulates an actual real-life alarm system, where an alarm goes off and doesn't shut off unless the homeowner manually shuts it off.
Several variations of this circuit can be done to fit your needs. Maybe you don't want a buzzer to sound and you actually want sirens to go off. In that case, you would swap out the buzzer for sirens. Maybe you want sirens and a buzzer to go off. In that case, you would wire the buzzer and the siren in parallel. With sufficient current, both will go off when the alarm is triggered by motion. You can customize the circuit to fit your needs.
And this is how a basic motion detector alarm circuit can operate.
To see how this circuit operates in real life, see the video below.
How to Build a Vibration Alarm Circuit
How to Build a Light Alarm Circuit
How to Build a Heat Alarm Circuit
How to Build a Tilt Alarm Circuit
How to Build a Door Alarm Circuit
How to Build a Motion Sensor Light Circuit
How to Build a Hall Effect Sensor Circuit
How to Build a Vibration Detector Circuit