User Manual
130
/
223
Connecting PIR sensors to a microcontroller is really simple. The PIR acts as a digital
output so all you need to do is listen for the pin to flip high (detected) or low (not
detected).
It’s likely that you'll want retriggering, so be sure to put the jumper in the H position!
Power the PIR with 5V and connect ground to ground. Then connect the output to
a digital pin. In this example, we'll use pin 7.
Code
After wiring, please open the program in the code folder- Lesson 17 HC-SR501 PIR
Sensor and click UPLOAD to upload the program. See Lesson 2 for details about
program uploading if there are any errors.
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.
Example picture










