How To Build A Motion Detection System

Arduino with PIR motion Sensor, LED and buzzer

A motion sensor (or motion detector) is an electronic device that is designed to detect and measure movement.

The sensor is designed to detect the infrared radiation emitted naturally from the human body .

When a person walks into the motion sensor’s field of detection, the difference in radiation creates a positive charge within the receiver; this perceived change causes the sensing unit to send electrical data to the embedded computer and hardware component to trigger Alarm.

Today we shall learn to use a PIR motion sensor with Arduino. The required kits are :

  1. An arduino and its adapter
  2. Few jumper Wires
  3. PIR motion sensor
  4. A LED
  5. A breadboard
  6. A buzzer

 

There are 3 pins on the PIR sensor. They are :

  1. Output-motion input pin
  2. GND-Ground pin
  3. VCC-positive power pin

There are two legs on a LED. The longer leg is positive and the shorter leg is negative. A buzzer has similar legs. The steps to setup hardware are listed below:

  • Connect 5V pin on the arduino to +VE on the breadboard .
  • Connect GND pin on the arduino to -VE on the breadboard .
  • Connect “VCC” pin of the sensor to +ve on the breadboard.
  • Connect Output pin to any analog or digital pins on the arduino.In this tutorial I connected it with A0
  • Connect “GND” ground pin on the sensor to -VE on the breadboard.
  • Fix the LED on the breadboard.
  • Connect longer LED leg to pin 13 on the arduino .
  • Connect shorter LED leg to GND pin on the breadboard through a 220 ohm resistor.
  • Fix buzzer on the breadboard.
  • Connect longer buzzer leg to pin 12(or any other pin) on the arduino.
  • Connect shorter buzzer leg to GND pin on the arduino.

 

 

The setup is complete. Now, upload the code and enjoy.

Check out the tutorial

 

(Code)

const int motionpin=A0;
const int ledpin=13;
const int buzzpin=12; // ledpin,motionpin and buzpin are not changed throughout the process
int motionsensvalue=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(ledpin, OUTPUT);
pinMode(motionpin,INPUT);
pinMode(buzzpin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
motionsensvalue=analogRead(motionpin); // reads analog data from motion sensor
if (motionsensvalue>=200){
digitalWrite(ledpin,HIGH);
tone(buzzpin,100); //turns on led and buzzer
}
else {
digitalWrite(ledpin,LOW); //turns led off led and buzzer
noTone(buzzpin);
}
}

 168 total views,  7 views today

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.