-
Notifications
You must be signed in to change notification settings - Fork 0
/
simon.py
48 lines (40 loc) · 1.37 KB
/
simon.py
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
import urandom
import oled
import buttons
import utime
import buzzer
def says():
while True:
try:
simon_list = []
print("starting simon from the top")
# adds number to list
for i in range(5): #rund through list inverting the selected oled in list for 1 second
r = urandom.randint(0,3)
simon_list.append(r)
oled.simonShow(simon_list)
utime.sleep_ms(100)
for i in simon_list:
while True:
utime.sleep_ms(10)
but = buttons.getOnly()
if not but:
continue
if but[0] != i:
buzzer.stop()
buzzer.wrongAnswer()
print("incorrect sequence")
buzzer.start()
utime.sleep_ms(100)
raise
print("correct sequence")
utime.sleep_ms(250)
break
buzzer.stop()
buzzer.rightAnswer()
buzzer.start()
utime.sleep_ms(50)
except Exception as e:
print(e)
continue
break