Skip to content

Instantly share code, notes, and snippets.

@oschettler
Created April 11, 2020 06:44
Show Gist options
  • Save oschettler/785b2a65b9e201e247cfef9b4f834561 to your computer and use it in GitHub Desktop.
Save oschettler/785b2a65b9e201e247cfef9b4f834561 to your computer and use it in GitHub Desktop.
Motion detector
# Detect motion
from gpiozero import Buzzer, MotionSensor
from time import sleep
buz = Buzzer(17)
pir = MotionSensor(4)
while True:
pir.wait_for_motion()
buz.on()
sleep(5)
buz.off()
pir.wait_for_no_motion()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment