-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmddet.py
More file actions
51 lines (43 loc) · 828 Bytes
/
Copy pathmddet.py
File metadata and controls
51 lines (43 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Import functions
from gpiozero import Button, LED
from time import sleep
import random
# Define variables to GPIO
red = LED(24)
green = LED(25)
#test
while True:
green.off()
red.on()
sleep(1)
red.off()
green.on()
sleep(1)
'''
# Inital setup
led.off()
time = random.uniform(3, 10)
#print(time)
# Loop watching for enthusiastic button pushes (instead of sleeping)
y = 0
check_period = 0.1
while y < time:
y = y + check_period
sleep(check_period)
# print(y)
if player_1.is_pressed:
print("Player 1 pressed too early!!")
exit()
if player_2.is_pressed:
print("Player 2 pressed too early!!") exit()
# OK - goooooooooooo!!!
led.on()
while True:
if player_1.is_pressed:
print("Player 1 wins!")
break
if player_2.is_pressed:
print("Player 2 wins!")
break
led.off()
'''