Home > Arduino Projects > PIR Sensor Tutorial 1
PIR sensors are pyroelectric or passive infrared sensors which can be used to detect changes in infrared radiation levels. The sensor is split in half, and any significant difference in IR levels between the two sections of the sensor will cause the signal pin to swing HIGH or LOW. Hence it can be used as a motion detector when IR levels move across and trigger the sensor (eg. human movement across a room). The potentiometers are used to adjust the amount of time the sensor remains on and off after being triggered. Essentially the delay between triggered events.

Here are a couple of pictures of the PIR sensor.



The sensor used in this tutorial is a HC-SR501 PIR sensor. You can get more information about this sensor here.

Parts Required


Sketch


PIR1_Fritzing Sketch

IMG_0669


Video




Sketch Explanation

The sketch described above can be used to test the functionality of the PIR sensor. I had another one of these sensors in my kit, and could not get it to work, no matter what I tried. The sensor would blink continuously even when there was no movement in the room. However, I must warn you, this specific sensor has an initialisation sequence which will cause the LED to blink once or twice in a 30-60sec timeframe. It will then remain off until the sensor detects movement. The amount of time that the LED remains on (when movement is detected) is controlled by one of the potentiometers.
Therefore, you could have it so that the LED blinks quickly or slowly after movement is detected.

If you set it to remain off for a long time, the sensor may appear to be unresponsive to subsequent movement events. Getting the timing right is mostly done out of trial an error, but at least the board indicates which side is min and which side is max.

Have a look at the PIR picture above for the potentiometer positions/timings that I used in the video.

For more awesome projects, or more info on this project, check out ScottC's Arduino Basics Blog