Making your own DIY motion sensor alarm with an Arduino is an easy and affordable way to add an extra layer of security to your home. With just a few simple components, you can build a device that will detect movement and sound an alarm, alerting you to any unwanted intruders.

What You Will Need

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

Arduino Board

The Arduino is the microcontroller board that will control the alarm. Any model will work, but the Arduino Uno is a good choice as it is inexpensive and widely available.

Passive Infrared (PIR) Motion Sensor

A PIR sensor detects motion by picking up changes in infrared radiation. When something moves within its range, like a person walking by, it will send a signal to the Arduino. You can get these very cheaply online.

Buzzer

A buzzer or small speaker will provide the audible alarm sound when motion is detected. A simple piezo buzzer that operates at 5V will work perfectly.

Jumper Wires

You'll need jumper wires to make all the connections between components. Both male-to-male and male-to-female wires will be useful.

Breadboard

A breadboard allows you to prototyped and connect everything without soldering. A half or full size breadboard will work.

9V Battery and Wire

An external 9V battery will power the Arduino and other components. Battery wires connect the battery to the breadboard rails.

Circuit Diagram

Here is a circuit diagram showing how everything needs to be connected:

The PIR motion sensor has three pins - 5V power, ground, and a signal pin that will input to a digital pin on the Arduino when motion is detected. The buzzer simply connects between a digital output pin on the Arduino and ground.

Setting Up the Hardware

Follow these steps to setup up the hardware for your Arduino motion alarm:

  1. Insert the Arduino into the breadboard, straddling the center divide.

  2. Connect the red battery wire to the 5V rail on the breadboard and the black wire to ground. This will power the Arduino when switched on.

  3. Insert the PIR sensor into the breadboard. Link its 5V and ground pins to 5V and ground on the breadboard.

  4. Connect the signal pin on the PIR to digital pin 2 on the Arduino.

  5. Insert the buzzer into the breadboard and connect one leg to digital pin 3 on the Arduino. Connect the other leg to ground.

Once everything is wired up as shown in the diagram, you are ready to move on to loading the alarm code onto the Arduino.

Uploading the Arduino Sketch

The Arduino needs to be programmed with code to monitor the PIR sensor pin and trigger the buzzer when motion is detected.

Install the Required Libraries

You'll need to have the Arduino IDE installed on your computer. Also, install the following libraries:

Arduino Motion Alarm Code

Here is the full Arduino code needed for the motion sensing alarm:

```cpp
/ Motion Sensor Alarm Code /

// Include required libraries

include

// Pin definitions
const int pirPin = 2; // PIR Out pin
const int buzzer = 3; // Buzzer pin

void setup() {

// Set buzzer as output
pinMode(buzzer, OUTPUT);

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

// Start serial monitor
Serial.begin(9600);

}

void loop() {

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

// Print results to serial monitor
Serial.print("Sensor status: ");
Serial.println(sensorStatus);

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

  // Sound alarm
  digitalWrite(buzzer, HIGH);

  // Delay to avoid rapid fire alarms
  delay(500);

} else {

  // No motion, turn off alarm  
  digitalWrite(buzzer, LOW);

  // Enter low power sleep mode until motion detected
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

}

}
```

The key points are:

Upload Sketch to Arduino

  1. Copy the code into a new sketch in the Arduino IDE. Save it.

  2. Make sure your Arduino is connected to your computer via USB.

  3. Select the correct board type and COM port.

  4. Click upload to compile and upload the code.

Once complete, the Arduino will run this motion sensing sketch whenever powered on.

Using Your Motion Alarm

You now have a fully functional DIY security alarm with the Arduino and PIR motion sensor!

To use it:

You can enhance the alarm further by:

So with very little effort you now have a smart motion detecting alarm system to improve security using DIY Arduino technology!