PIR Sensor - HC-SR501

Overview

Smiley face

PIR sensor which is also known as Pyroelectric sensor or Passive Infrared Sensor is basically an electronic sensor employed in motion detecting applications. A PIR sensor detects or measures IR (Infra-Red) radiations emitted by any object inside its field of view. A PIR sensor is generally known to the world as motion sensor or motion detector.

Working of LDR

Smiley face

The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected.

Interface with Arduino

Smiley face

The PIR sensor module has got only one digital output mode. So it has only 2 possible output values – either a HIGH or a LOW. By default, standards, when there is no object inside the range of PIR sensor it outputs a LOW value or 0V at output. When an object is identified inside the range of PIR sensor it immediately outputs a HIGH value or +5V at output.

Arduino Code

int inputPin = 7;               // choose the input pin (for PIR sensor)
int val = 0;                    // variable for reading the pin status
void setup() {
    pinMode(inputPin, INPUT);     // declare sensor as input
    Serial.begin(9600);
}
 void loop(){
 val = digitalRead(inputPin);
 Serial.println(val);
 }
		

Next : Ultra Sonic Sensor - HC-SR04