Motion sensor alarms can be useful for home security or other applications. With an Arduino microcontroller, it's possible to build a simple motion alarm yourself. In this article, I will walk through the complete process of making an Arduino motion sensor alarm that few people know about.

What You Will Need

To build this alarm, you will need:

I'll explain each part in more detail shortly. This is a very simple build with common components that are easy to find.

How a PIR Motion Sensor Works

A PIR (passive infrared) motion sensor is the key component that allows the Arduino to detect movement in a room.

PIR sensors can detect changes in infrared radiation, allowing them to effectively sense motion and body heat. They have two sensitive elements connected in a wheatstone bridge configuration. When motion is detected, it causes a difference in voltage between the two elements. This difference is amplified and sent as a high or low signal to the Arduino.

The PIR sensor has a range of about 6-7 meters and a wide 120° field of view. This makes it great for detecting motion in a room. And it can detect motion up to 3-5 meters away depending on conditions.

Hooking up the Motion Sensor

Hooking up a PIR motion sensor to the Arduino is very simple. Here is what you need to do:

The OUT pin will go HIGH when motion is detected. We'll detect this change in our Arduino code.

Adding a Buzzer

To make noise when motion is detected, we need to hook up a buzzer or piezo speaker to the Arduino.

Connect one leg of the buzzer to Arduino pin 8, and the other leg to GND. I put a 220 ohm resistor in series with the positive leg to limit current.

Now when pin 8 is set HIGH in code, the buzzer will sound.

Putting it Together on a Breadboard

For compact testing, I put all the components together on a solderless breadboard like this:

The breadboard lets you easily connect everything with jumper wires.

Of course, once you have it working you can make it standalone by mounting the components in an enclosure.

Arduino Motion Sensing Code

Here is simple Arduino code to detect motion with the PIR sensor and sound the buzzer alarm:

const int pirPin = 7; // PIR Out pin connected to pin 7
const int buzzer = 8; // Buzzer connected to pin 8

void setup() {

pinMode(pirPin, INPUT); // Set PIR pin as input
pinMode(buzzer, OUTPUT); // Set buzzer pin as output


void loop(){

if (digitalRead(pirPin) == HIGH) { // If motion detected

digitalWrite(buzzer, HIGH);   // Sound alarm

} else {

digitalWrite(buzzer, LOW);    // Turn off alarm when no motion



When motion is detected, the PIR pin goes high. This triggers the buzzer alarm until motion is no longer present.

Adjusting Sensitivity and Delay

Most PIR sensors have onboard potentiometers you can tweak to adjust detection sensitivity and delay time.

Turn the sensitivity knob to control the range. Higher values detect motion further away.

The delay knob sets how long the alarm stays active after motion is detected. Turn it up to keep the buzzer sounding longer.

Adjust these pots as needed for your specific room setup.

Final Assembly and Testing

Once you have the code working, install the components into an enclosure or case with the PIR facing outward. This helps protect them and keeps the sensor stabilized.

Make sure to position the sensor so it has a clear view of the area you want to detect motion. Try to avoid pointing it at windows, heaters, fans or other sources that could cause false alarms.

Finally, upload your code and test it out! Walk in front of the PIR sensor and the buzzer should sound each time.

Now you've got a simple Arduino motion alarm that's easy to build yet works surprisingly well. With this customizable setup, you can enhance home security on a budget.