How to Build a Low-Cost Motion Sensor Alarm with an Arduino and PIR Sensor


Building a motion sensor alarm with an Arduino and a passive infrared (PIR) sensor is an easy and affordable way to add motion detection to your home security system. The components are readily available, and with just a bit of coding, you can have a fully functional motion alarm up and running in no time.

In this guide, I will walk through the entire process step-by-step, from gathering materials to uploading code, to help you build your own low-cost motion sensor alarm.

Gather the Required Components

To build the motion sensor alarm, you will need the following components:

Optionally, you can also add an LED, resistors, a switch, and a prototyping shield to expand the capabilities of the alarm.

Assemble the Circuit

Here are the steps to assemble the motion sensor alarm circuit:

  1. Connect the PIR sensor to Arduino pin 2 and ground.

  2. Connect the positive lead of the buzzer to Arduino pin 3. Connect negative lead to ground.

  3. Connect the 9V battery to the Arduino using the battery clip, paying attention to polarity.

  4. Optionally, connect an LED and resistor from pin 13 to ground to use the built-in LED.

  5. Use a switch to connect from Arduino reset to ground to turn on/off.

  6. If using a prototyping shield, simply plug into Arduino.

Refer to the circuit diagram and make sure all components are securely connected. Double check polarity when using the battery.

Load and Test the Code

With the hardware ready, it is time to load the Arduino sketch. This is the code that controls the alarm:

  1. Download the motion sensor alarm code from this link.

  2. Open the sketch in the Arduino IDE.

  3. Verify and upload the code to the Arduino board.

  4. Open the Serial Monitor at 115200 baud to see sensor readings.

  5. Wave your hand in front of the PIR to trigger the alarm and LED. Adjust sensitivity as needed.

  6. Once satisfied, disconnect USB and power Arduino via the 9V battery.

The PIR motion sensor alarm is now ready for installation and use!

Install and Use the Motion Sensor Alarm

To install your DIY motion sensor alarm:

With this simple Arduino motion sensor alarm, you can inexpensively monitor areas like driveways, sheds, and corridors for unexpected activity.


Building your own motion sensor alarm with Arduino provides a customizable and budget-friendly solution for enhanced home security. This guide covers how to assemble the circuit, install code, and configure the PIR sensor for optimal motion detection. With just a few components, you can now monitor your property and possessions for unexpected intruders. Be sure to check out the links below for more ideas on enhancing this project. The possibilities are endless when leveraging the versatility of Arduino!