HC-SR501 PIR motion sensor on Arduino

HC-SR501
HC-SR501

The HC-SR501 PIR motion sensor is one of the easiest to connect to an Arduino -or any other microcontroller for that matter- and can also be used as a stand alone motion detector.
hc-sr501The HC-SR501 board has 2 variable resistors: looking at the back, with the connections facing upwards and the variable resistors at the bottom, the left resistor is for sensitivity and the right one is for output timing.
for the sensitivity goes: Clockwise=>High sensitivity CCW=> low sensitivity (3-7 m). for the Output timing it is CW=>long, CCW=> short (3-300 sec)
The right prong of the connector is for Vcc (+5-20V), the middle one is signal out and the left one is ground. The output is either high (3.3V) or low (0v)

There are two versions of the board. One with a 3 prong jumper and one with solder pads insted 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.

The Logic in the sensor is the known BISS0001
HC-SR501-c

/* ---------------------------------------------------
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));
}