PIR SENSOR

 PIR SENSOR

                   PIR is abbreviated as Passive Infrared Sensor. It is used to sense motion, used to detect whether a human has moved in or out of the sensor range. PIRs are basically made of a pyro electric sensor, which can detect the levels of IR radiation. Every object that has a temperature above perfect zero emits thermal energy in form of radiation. The sensor gives different output in the form of electrical signals depending upon temperature of different objects.We can interface PIR sensor with Arduino to detect the motion of objects. 
 


Application:

  • It can be used as Motion planning.
  • It can be used in Security Alarm System.
  • It is used in Automatic Door Opening System.
  • It can be used as Human Detection Robot.

Sample Project With Arduino:

                                   In this we going to turn ON the LED whenever the motion is detected by the PIR sensor and turn OFF the LED whenever the motion is not detected.

Material required:

  • ARDUINO UNO Board
  • PIR  Sensor
  • LED
  • Jumper wires

Circuit:


Code:

int led = 13;  // the pin that the LED is attached to
int sensor = 2;  // the pin that the sensor is attached to
int state = LOW;  // by default, no motion detected
int val = 0;  // variable to store the sensor status (value)

void setup() {
  pinMode(led, OUTPUT);  // initalize LED as an output
  pinMode(sensor, INPUT);  // initialize sensor as an input
  Serial.begin(9600);  // initialize serial
}

void loop(){
  val = digitalRead(sensor);  // read sensor value
  if (val == HIGH) {  // check if the sensor is HIGH
    digitalWrite(led, HIGH);  // turn LED ON
    delay(100);  // delay 100 milliseconds 
    
    if (state == LOW) {
      Serial.println("Motion detected!"); 
      state = HIGH;  // update variable state to HIGH
    }


  else {
      digitalWrite(led, LOW);  // turn LED OFF
      delay(200);  // delay 200 milliseconds 
      
      if (state == HIGH){
        Serial.println("Motion stopped!");
        state = LOW;  // update variable state to LOW
    }
  }
}

 


Comments

Popular posts from this blog

Voice Record & Playback Module

GSM Sim800L

GPS