PIR Motion Sensor Alarm using Arduino

We are designing PIR motion sensor alarm project. It is used to deter the trespasser who enters into the restricted area.

This security system is based on PIR motion sensor and arduino interfacing. By using the PIR sensor we can detect the trespassers and intruders entering in the restricted area.

When a motion is detected by the PIR sensor it sends the signal to the arduino. Once receiving the signal arduino triggers the alarm ON. The main aim of this project is to deter the trespassers and intruder.

How to Build PIR Motion Sensor Alarm Project

We need to know some basic interfacing of PIR sensor and buzzer(alarm) with the arduino.

To make the project reliable we have implemented the code using the Arduino Interrupt. When the input priority is high like in fire alarm and security system. We should consider the input using the interrupt so the system will process such input before the other system activity. And input never misses by the system.

This PIR sensor is connected to the arduino pin 2 that is dedicated for interrupt 0. The interrupt will be triggered at the rising edge of the input. And after receiving the interrupt it will call a function(ISR) alarmON.

PIR Pinout

Pin Name Function
GND Connects to Ground or Vss
+ Vcc Connects to Vdd (3.3V to 5V) @ ~100uA
OUT Output Connects to an I/O pin set to INPUT mode

Hardware Required

  • Arduino Uno
  • PIR Motion Sensor
  • Buzzer
  • Breadboard

PIR Motion Sensor Alarm Arduino Connection

PIR Motion Sensor Alarm Arduino Circuit

Motion Sensor Alarm Arduino Code

We have implemented the interrupt 0 at rising edge of motion sensor input.

attachInterrupt(0, alarmON, RISING)

This is external hardware interrupt of atmega. Here alarmON is the function(ISR) where we have put the code to ON the alarm. This calls the ISR when only a rising edge of input is present at pin 02. Once the alarm is ON it will be ON forever. To stop the alarm press the reset button of the arduino.

/*#####PIR Motion Sensor Light Switch Arduino Project####
Connection:
Buzzer         - Digital Pin 13
Motion Sensor  - Digital Pin 02
And Connect the supply to above module*/

int buzzer = 13;
void setup()
{
  pinMode(buzzer, OUTPUT);    // Buzzer as output
  digitalWrite(buzzer, LOW);  //make Buzzer OFF
  //PIR Motion Sensor connected at digital pin 2 i.e. interrupt 0
  attachInterrupt(0, alarmON, RISING); 
}

void loop()
{   

}

void alarmON()
{ 
  // Alarm ON  
  digitalWrite(buzzer, HIGH); 
}

Leave a Reply

Your email address will not be published. Required fields are marked *