1+ import machine
2+ import time
3+
4+ import button
5+
6+ button_a = button .Button (15 )
7+ button_b = button .Button (27 )
8+
9+ import music
10+
11+ music .play (music .POWER_UP )
12+
13+ import display
14+
15+ Image = display .Image
16+ display = display .Display ()
17+
18+ display .clear ()
19+
20+ all_boats = [
21+ Image ("00000:" "00000:" "00000:" "00000:" "00000" ),
22+ Image ("11111:" "00000:" "00000:" "00000:" "00000" ),
23+ Image ("11111:" "11111:" "00000:" "00000:" "00000" ),
24+ Image ("11111:" "11111:" "11111:" "00000:" "00000" ),
25+ Image ("11111:" "11111:" "11111:" "11111:" "00000" ),
26+ Image ("11111:" "11111:" "11111:" "11111:" "11111" ),
27+ Image ("00000:" "11111:" "11111:" "11111:" "11111" ),
28+ Image ("00000:" "00000:" "11111:" "11111:" "11111" ),
29+ Image ("00000:" "00000:" "00000:" "11111:" "11111" ),
30+ Image ("00000:" "00000:" "00000:" "00000:" "11111" ),
31+ Image ("00000:" "00000:" "00000:" "00000:" "00000" ),
32+ ]
33+
34+ display .show (all_boats , color = (10 , 10 , 10 ), delay = 150 )
35+
36+ music .play (music .JUMP_UP )
37+ display .show ('A' , color = (20 , 0 , 0 ))
38+ while 0 == button_a .was_pressed ():
39+ time .sleep (0.1 )
40+ time .sleep (0.5 )
41+ display .show ('O' , color = (0 , 20 , 0 ))
42+
43+ music .play (music .JUMP_UP )
44+ display .show ('B' , color = (20 , 0 , 0 ))
45+ while 0 == button_b .was_pressed ():
46+ time .sleep (0.1 )
47+ time .sleep (0.5 )
48+ display .show ('O' , color = (0 , 20 , 0 ))
49+
50+ music .play (music .JUMP_UP )
51+ display .show ('T' , color = (20 , 0 , 0 ))
52+ import temperature
53+ __adc = machine .ADC (machine .Pin (35 , machine .Pin .IN ))
54+ __adc .atten (machine .ADC .ATTN_11DB )
55+ temperature = temperature .Temperature (__adc ).temperature
56+
57+ time .sleep (1 )
58+ while temperature () < 10 :
59+ time .sleep (1 )
60+ display .show ('O' , color = (0 , 20 , 0 ))
61+
62+ music .play (music .JUMP_UP )
63+ display .show ('9' , color = (20 , 0 , 0 ))
64+ __i2c = machine .I2C (scl = machine .Pin (22 ), sda = machine .Pin (21 ), freq = 200000 )
65+ while True :
66+ __dev = __i2c .scan ()
67+ if len (__dev ) > 0 :
68+ buf = bytearray (1 )
69+ while buf [0 ] != 234 :
70+ __i2c .readfrom_mem_into (__dev [0 ], 0 , buf )
71+ time .sleep (1 )
72+ # print(buf[0])
73+ break
74+ display .show ('O' , color = (0 , 20 , 0 ))
75+
76+ music .play (music .JUMP_UP )
77+ display .show ('L' , color = (20 , 0 , 0 ))
78+ time .sleep (0.5 )
79+ import light
80+ lt = light .Intensity (34 )
81+ while True :
82+ last = lt .read ()
83+ time .sleep (1 )
84+ now = lt .read ()
85+ if abs (now - last ) > 100 :
86+ break
87+ display .show ('O' , color = (0 , 20 , 0 ))
88+
89+ music .play (music .POWER_DOWN )
90+ time .sleep (0.5 )
91+ display .clear ()
0 commit comments