Raspberry Pi practice problem · Sensors
Visitor counter
EasyBudget $6Python · gpiozero
A PIR motion sensor with OUT on GPIO4 (power it from 5 V). Count visitors: each time OUT goes high, add one and print the new total:
Visitors: 1
OUT stays high for about 5 s after each visit, so print once per visit, not once per loop. The test sends visitors at 1 s, 10 s and 19 s.
Tip: gpiozero's when_motion callback runs once per rising edge.