Created
August 13, 2017 08:58
-
-
Save uktechreviews/2e144546036b63d8ce47c3f72e51f527 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import MotionSensor | |
from gpiozero import LED | |
from time import sleep | |
import random | |
green = LED(20) | |
red = LED(21) | |
sensor = MotionSensor(4) | |
while True: | |
print ("Starting again") | |
sleep(2) | |
red.on() | |
moved = False | |
wait = random.randint(0,5) | |
red.off() | |
green.on() | |
sleep(wait) | |
green.off() | |
red.on() | |
while moved==False: | |
if sensor.motion_detected: | |
print ("Spotted you move") | |
moved = True | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment