Building a motion sensor alarm with an Arduino is a straightforward electronics project that can help protect your valuables. With just a few common components, you can construct a device that sets off an audible alarm whenever movement is detected.

An Overview of the Required Components

To build a basic motion sensing alarm with an Arduino, you will need:

Assembling the Motion Sensor Circuit

With the components gathered, we can now assemble our motion alarm circuit:

Step 1 - Connect the PIR sensor

The PIR motion sensor has 3 pins - power, ground, and signal.

Step 2 - Connect the buzzer

The buzzer also has 2 pins - one for power and one for ground.

Step 3 - Power the Arduino

Use the 9V battery clip to provide power to the Arduino. Connect the red wire from the clip to the 5V pin on the Arduino, and the black wire to a ground pin.

The motion sensor circuit is now assembled! The PIR will detect movement and output a high signal on its signal pin. The Arduino will detect this signal and activate the buzzer to sound the alarm.

Programming the Arduino Motion Alarm

Now that our circuit is wired up, we need to upload a program to the Arduino to operate the alarm:

Step 1 - Initialize variables

At the start of the program, we need to initialize some variables:

int buzzer = 3; //buzzer connected to pin 3
int PIRpin = 2; //PIR connected to pin 2

Step 2 - Setup code

In the setup() function, we set the pin modes and initialize the serial monitor:

void setup() {

pinMode(buzzer, OUTPUT);
pinMode(PIRpin, INPUT);



Step 3 - Main loop

In the loop(), we continuously check the PIR for motion. If motion is detected, we activate the buzzer:

void loop(){

if (digitalRead(PIRpin) == HIGH) {

digitalWrite(buzzer, HIGH);
Serial.println("Motion Detected!");


digitalWrite(buzzer, LOW);



This simple program is all we need to detect motion and sound the alarm!

The full Arduino sketch can be found in the GitHub repo linked below.

Testing and Using the Motion Alarm

With the code uploaded to the Arduino, our motion alarm project is complete!

To test it out, simply power up the Arduino and walk in front of the PIR sensor. The buzzer should sound each time motion is detected.

The alarm can be placed anywhere you need motion notifications - in a mailbox, near a door or window, etc. The buzzer will loudly alert you whenever the sensor triggers.

Some ways to improve or expand the project could include:

With an Arduino, a PIR sensor, and a buzzer you can easily construct a DIY motion alarm for under $20. This simple project is a great way to help monitor and protect your belongings!

The full code for the project can be found on this GitHub page.