PIR Motion Sensor Using Arduino Uno

PIR Motion Sensor Using Arduino Uno


This project is used to sense motion. When a warm body like a human or animal has moved in or out of the sensors range. A light bulb will light up when movement is detected.

Components required 

Hardware

  • Arduino UNO

  •  Passive infrared sensor (PIR sensor)

  • 5 V 1 channel Relay Module
  • Light bulb

  • Jumper/Connecting Wires

  • 5 V DC Adapter

Software
  • Arduino IDE

Warning: - AC is very risky and accidental shock could be fetal, so be sure to pursue appropriate safety precautions.  Predictable Designs assumes no accountability for any injury that may happen by following this tutorial.



Circuit and Working

The circuit is built using Arduino Uno, PIR sensor and a 1-channel relay

The step-wise working is as follows:

      Step1: Upload the sketch in Arduino Uno. A Sample sketch is shown below: 

int bulb = 7;                // Bulb
int pirsensor = 2;                 // PIR Out pin
int pirstatus = 0;                   // PIR status
void setup() {
 pinMode(bulb, OUTPUT);   
 pinMode(pirsensor, INPUT);   
 Serial.begin(9600);
}
void loop(){
 pirstatus = digitalRead(pirsensor);
 if (pirstatus == HIGH) {            // if motion detected
   digitalWrite(bulb, HIGH);  // turn bulb ON
   Serial.println("Motion Detected ");
 }
 else {
   digitalWrite(bulb, LOW); // turn LED OFF if we have no motion
 }
}


Step 2: Connect Relay with Arduino Uno
Relay      Adruino Uno
IN1      >   Pin 7
GND   >    GND
VCC   >     5V

Step 3: Connect PIR sensor with Arduino Uno
PIR Sensor                             Adruino Uno
OUT                                 >        Pin 2
GND                                >        GND
VCC                                >         5V

Step 4: Connect Relay and light bulb as shown below

Step 5: Power the light bulb and Adruino Uno (use 5V Adapter)

Comments