Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Raspberry Pi) expand_more
Raspberry Pi / Hardware Projects

PIR motion sensor

Learn PIR motion sensor in Raspberry Pi with a dedicated explanation, a concept-specific example, practical cautions, and a mastery check.

12 min read • Advanced
raspberry-pi-046.py
python
from gpiozero import MotionSensor
pir=MotionSensor(4)
pir.wait_for_motion(); print('motion detected')
pir.wait_for_no_motion(); print('clear')
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content