Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, random
- from gpiozero import LED, Button
- led1 = LED(23)
- # test
- led1.on()
- time.sleep(2)
- led1.off()
- button1 = Button(25)
- end = "Y"
- best = 100
- print("press buttonn when LED is on")
- while end =="Y":
- time.sleep(random.randint(1,5))
- start = time.time()
- led1.on()
- button1.wait_for_press()
- button1.when_pressed = led1.off()
- stop = time.time()
- duration = stop-start
- print("reaction time in s",duration)
- if duration<best:
- best = duration
- print("You got a lowscore!")
- end = input("Again [Y]es/[N]o ")#I've got no second button
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement