HC-SR501 PIR Motion Sensor On Arduino
HC-SR501 PIR Motion Sensor On Arduino
on Arduino
HC-SR501
There are two versions of the board. One with a 3 prong jumper and one
with solder pads instead of a jumper. If the jumper is put in its bottom
position (with the board still facing as described) there is no reset. If it is
in its top position (H) it is in auto reset mode. If set to Auto-reset the
sensor will stay high until the motion stops. After motion is no longer
detected the output will go low. If set to No reset (L) the sensor will stop
sensing once it has triggered, and stays high for the preset time period.
To choose one of these settings, simply create a solder-bridge between
the labelled pad and the pad in the middle. the default as i understand is
‘L’
If you search internet for info about this module, you may come across
contradicting info about which is ‘L’ and which is ‘H’ On my board it is as
described: if the solder pads are in the lower-left corner, ‘L’ is the bottom
one and ‘H’ the top one.
/* ---------------------------------------------------
using an HC-SR501 PIR sensor
Sensor on D2
LED on D13
----------------------------------------------------*/
void setup(){
pinMode(13,OUTPUT);
pinMode(2,INPUT);
}
void loop(){
digitalWrite(13,digitalRead(2));
}