SR501 Motion Sensor
SR501 Motion Sensor
User Guide
Brief Data:
2 www.handsontec.com
Device Area of Detection:
The device will detect motion inside a 110 degree cone with a range of 3 to 7 meters.
PIR Range (Sensitivity) Adjustment:
As mentioned, the adjustable range is from approximately 3 to 7 meters. The illustration
below shows this adjustment. You may click to enlarge the illustration.
3 www.handsontec.com
Time Delay Adjustment:
The time delay adjustment determines how long the output of the PIR sensor module will
remain high after detection motion. The range is from about 3 seconds to five minutes. The
illustration below shows this adjustment.
Example 1:
In this first example, the time delay is set to 3 seconds and the trigger mode is set to single.
As you can see in the illustration below, the motion is not always detected. In fact, there is a
period of about 6 seconds where motion cannot be detected.
5 www.handsontec.com
Example 2:
In the next example, the time delay is still at 3 seconds and the trigger is set to repeatable. In
the illustration below, you can see that the time delay period is restarted. However, after that
3 seconds, detection will still be blocked for 3 seconds.
As mentioned previously, you could override the 3 second blocking period with some
creative code, but do give that consideration. Some of the electronics you use may not like
an on and then off jolt. The 3 seconds allows for a little rest before starting back up.
6 www.handsontec.com
Copy, Paste and Upload the Tutorial Sketch:
The sketch simply turns on Your Arduino LED connected to Pin 13 whenever motion is
detected. Be sure to beware of and somehow handle the 1 minute initialization in whatever
application you develop.
/*
Arduino with PIR motion sensor
For complete project details, visit: http://RandomNerdTutorials.com/pirsensor
Modified by Rui Santos based on PIR sensor by Limor Fried
*/
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
}
}
7 www.handsontec.com
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
}
}
}
Schematic Diagram:
8 www.handsontec.com