Created
August 21, 2017 16:04
-
-
Save uktechreviews/981b1691550930d85c759e57dbe175c9 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 Button | |
from gpiozero import LED | |
from time import * | |
import time | |
import random | |
button = Button(21) | |
green =LED(14) | |
yellow=LED(15) | |
green.on() | |
yellow.off() | |
wait = random.randint(2,7) | |
sleep(wait) | |
start_time = time.time() | |
while True: | |
if button.is_pressed: | |
yellow.off() | |
end_time = time.time() | |
elapsed_time = end_time - start_time | |
print ("You took " + "%.2f" %elapsed_time + " seconds") | |
break | |
else: | |
yellow.on() | |
green.off() | |
green.off() | |
yellow.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment