How to Make a Simple Motion-Activated Alarm with An Arduino and a PIR Sensor


Making a motion-activated alarm with an Arduino and a passive infrared (PIR) sensor is an easy and fun electronics project. The alarm will detect motion using the PIR sensor and sound an audible alert. This project is a great way to learn about Arduino programming and basic alarm circuits. With just a few components, I can build my own security system to protect my valuables.

In this article, I will provide a step-by-step guide on how I built the motion-activated alarm using the following components:

I will cover how to assemble the circuit, program the Arduino, and adjust the PIR sensor. By the end, I will have a working alarm that sounds an audible alert whenever motion is detected. Let's get started!

What I Need

To build the motion-activated alarm, I will need the following components:

Arduino Uno

The Arduino Uno is a microcontroller board that will control the alarm system. It will run the code and trigger the buzzer when motion is detected.

PIR Sensor

The PIR (passive infrared) sensor is used to detect motion. It is able to detect changes in infrared radiation levels, allowing it to sense when a human or animal passes in front of it.


The buzzer will provide the audible alert when motion is detected. Any small 5V buzzer will work.


An LED is used to visually indicate when motion has been detected. Pick any color LED.


Jumper Wires

Jumper wires are used to connect the components to the Arduino board and breadboard.


A breadboard provides a convenient way to mount the circuit temporarily.

Circuit Diagram

Before assembling the circuit, here is a circuit diagram showing how all the components will be connected:

How to Make a Simple Motion-Activated Alarm with An Arduino and a PIR Sensor

The PIR sensor, LED, buzzer, and resistor will be connected to the Arduino board via the breadboard. The Arduino will provide power and control the alarm.

Assembling the Circuit

With the components ready, it's time to assemble the alarm circuit:

Step 1: Insert the Arduino into the Breadboard

Place the Arduino board onto the breadboard. Make sure the front of the Arduino with all the labels is facing you. The Arduino will provide power to the alarm components through the 5V and GND pins.

Step 2: Connect the PIR Sensor

This allows the PIR sensor to draw power from the Arduino and send motion detection signals to pin 2.

Step 3: Connect the Buzzer

The buzzer will emit sound when activated by pin 3. The resistor limits the current flowing to the buzzer.

Step 4: Connect the LED

The LED provides a visible alert whenever the PIR detects motion.

That completes the circuit! Double check that all components are securely connected.

Arduino Sketch

Now that the hardware is assembled, the Arduino needs to be programmed to trigger the alarm components when motion is detected.

I will use the Arduino IDE to write and upload the following sketch:

// Define pins
const int pirPin = 2;
const int buzzerPin = 3;
const int ledPin = 4;

void setup() {

// Set LED and buzzer pins as Outputs
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);

// Print message to serial monitor
Serial.println("Motion alarm active!");

// Set PIR pin as Input
pinMode(pirPin, INPUT);

void loop(){

// Read PIR state
int pirValue = digitalRead(pirPin);

// If motion detected
if (pirValue == HIGH) {

// Sound buzzer
tone(buzzerPin, 1000);

// Turn on LED
digitalWrite(ledPin, HIGH);

// Print message
Serial.println("Motion Detected!");

// Delay

// Turn off buzzer and LED
digitalWrite(ledPin, LOW);


// Brief delay

This sketch continuously checks the PIR sensor for motion. When motion is detected, it triggers the buzzer and LED alert, then delays briefly before resetting. The serial monitor will also print out messages so I can monitor the alarm status.

After double checking the code, I can upload it to the Arduino through the USB cable.

Testing and Adjusting the PIR Sensor

Once programmed, I'm ready to test out the motion alarm!

I will need to make some adjustments to properly configure the PIR sensor:

I should experiment with different settings to get the alarm working just the way I want. Higher sensitivity and longer time delay can reduce false triggers, but may also miss some motions.

The PIR sensor has a detection range of up to 6 meters, but works best within 5 meters. It has a 120° field of view.


Building a motion-activated alarm with an Arduino and PIR sensor turned out to be both fun and informative. I learned how to connect sensor components to the Arduino and program it to control an alarm system. The finished alarm reliably detects motion and triggers visible and audible alerts.

Some ways I can expand this project include:

I now have the knowledge to build more sophisticated Arduino projects. This alarm provides a great foundation to learn and experiment!