PIR motion sensor HC-SR501 with TinkerPie
Senses body heat moving: burglar alarms, automatic lights.
| Type | Digital sensors |
|---|---|
| Connect to | any accessory pin |
| Gives | true while a person moves |
| Simulator | Yes: a control appears under the simulated board |
How it works
A PIR (passive infrared) sensor notices changes in the infrared heat coming from its surroundings. When a warm body moves in front of it, the pattern changes and the output switches on. The white dome is a lens that collects heat from a wide area.
How to wire it
Signal (DO / OUT / S) to any accessory pin: S1-S4, P10-P13, P43 or P44. Power from 3.3 V where the module allows it.
Code
In blocks: Accessories category in TinkerPie Studio. As code:
// JavaScript
sensors.pirMotion(Pin.S1)
// Arduino C++
sensors::pirMotion(Pin::S1) Good to know
- Range about 3-7 m in a wide cone (around 110°).
- Give it 30-60 seconds to settle after power-up.
- Two orange knobs set the sensitivity and how long the output stays on.
Projects with the PIR motion sensor HC-SR501
Similar modules
- IR obstacle sensor
- Touch sensor TTP223
- Push button module
- Tilt switch SW-520D
- Reed switch (magnet)
- Vibration sensor SW-420
- Hall effect sensor A3144
- Line tracker TCRT5000
More projects to try
Questions
Can I try the PIR motion sensor HC-SR501 without buying one?
Yes. In TinkerPie Studio the simulator shows a control for it under the board, so you can test your program before you build it.
Why does the PIR not notice me when I stand still?
It senses movement of warm bodies, not presence. If you stay still, the heat pattern does not change. To sense a person who is still, try the AI camera.