Having a home security system that alerts me when there is unexpected motion in or around my house helps me sleep better at night. As a DIY enthusiast, I wanted to build my own simple and affordable motion sensing alarm that would detect intruders and alert me right away.

In this guide, I will walk through the entire process of building a basic electronic motion sensor alarm from start to finish using common electronic components. I will cover what parts you need, how to assemble the circuit on a breadboard, how to program the microcontroller, and how to install the sensor and configure the alarm system.

Overview of the Motion Sensor Alarm System

The alarm system consists of three key components:

Motion Sensor

This is a passive infrared (PIR) sensor that detects motion by monitoring infrared radiation. It can detect the motion of people within its coverage area.


This acts as the brain of the alarm system. I used an Arduino Uno board which is easy to program. When the sensor detects motion, it will activate the alarm routine on the Arduino.


This audio alarm will sound loudly when motion is detected to scare away intruders and alert me. I used a common piezo buzzer module.

Parts and Tools Needed

Building this motion alarm requires some basic electronic components. Here's what I used:

You will also need basic tools like a soldering iron, wire cutters, wire strippers, and screwdrivers. Make sure you have these on hand before starting.

Step 1: Assemble the Circuit on the Breadboard

The first step is to assemble the basic circuit on a breadboard before transferring it to a permanent prototype board.

I connected the PIR sensor pins to the Arduino as follows:

Next, I connected the piezo buzzer:

Finally, I added an LED with a resistor:

This circuit provides the basic connections we need to detect motion, sound the alarm, and light up an LED indicator.

Step 2: Install Arduino IDE and Load Code

To program the Arduino board, you need to install the Arduino IDE on your computer. This is the software that will allow us to load code onto the board.

Here are the steps to install the IDE:

  1. Download the Arduino IDE from
  2. Install the IDE by following the setup wizard.
  3. Once installed, open the Arduino app.

Next, I copied the following code and loaded it into the IDE:

int pirPin = 2; //PIR Out pin connected to pin 2
int ledPin = 13; //LED connected to pin 13
int buzzer = 11; //Buzzer connected to pin 11

void setup() {

pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
pinMode(buzzer, OUTPUT);


void loop(){

if (digitalRead(pirPin) == HIGH) {

digitalWrite(ledPin, HIGH);   //Turn ON LED
tone(buzzer, 1000); //Play tone on Buzzer

digitalWrite(ledPin, LOW); //Turn OFF LED
noTone(buzzer);  //Stop tone on Buzzer

else {

digitalWrite(ledPin, LOW); //Turn OFF LED



This code initializes the pins, then continuously checks if motion is detected. If motion is detected, it turns on the LED, sounds the buzzer alarm, waits, and repeats.

After loading the code, I clicked Upload to compile it and upload it to the Arduino board.

Step 3: Transfer the Circuit to a Prototype Board

Now that the circuit is tested and programmed, I soldered all the components onto a prototype printed circuit board (PCB) for a permanent installation.

I first soldered header pins to the Arduino so it could plug into the board.

Next, I soldered the PIR sensor, buzzer module, LED, and resistors to the PCB as per the breadboard diagram.

The final board now has a solid alarm circuit ready for installation in my home.

Step 4: Install the Motion Sensor

With the alarm circuit ready, I now had to install the PIR motion sensor in a suitable location.

I mounted the sensor module on the wall in a hallway with a good view of the entryway and any motion corridors. This allowed it to effectively detect intruders.

I positioned the sensor about 7 feet off the ground and angled it slightly downward. This prevented false alarms from pets low to the ground.

Step 5: Configure the Sensitivity and Alarm Loudness

The PIR sensor has a sensitivity dial that can be adjusted as needed. I turned it to maximum sensitivity to start.

The alarm buzzer volume can be configured in the Arduino code. I set it to 1000 Hz but this can be increased for a louder alarm sound.

Finally, I adjusted the alarm delays in the code to avoid false alarms. Longer delays of 2-3 seconds worked best before re-triggering the alarm.


Building your own motion sensing alarm is a fun electronics project that gives you peace of mind. This alarm system alerts me when unwanted visitors enter my home, allowing me to take action.

With basic Arduino skills and electronic components, you can easily construct the alarm circuit and customize it as needed. Position the sensor properly to avoid false triggers. And adjust settings like sensitivity and alarm volume to fit your space.

With this DIY motion sensor alarm in place, I can now sleep soundly knowing my home is protected.