-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicrobit_on_monitor.py
120 lines (100 loc) · 2.77 KB
/
microbit_on_monitor.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from microbit import *
import radio
reversed = True # If the microbit is upside down, set this to true, otherwise it can be false.
rotat90 = Image("00200:"
"00200:"
"00200:"
"00200:"
"00200:")
rotat2 = Image("02000:"
"00200:"
"00200:"
"00200:"
"00020:")
rotat3 = Image("02000:"
"02000:"
"00200:"
"00020:"
"00020:")
rotat4 = Image("20000:"
"02000:"
"00200:"
"00020:"
"00002:")
rotat5 = Image("00000:"
"22000:"
"00200:"
"00022:"
"00000:")
rotat6 = Image("00000:"
"20000:"
"02220:"
"00002:"
"00000:")
rotatflat = Image("00000:"
"00000:"
"22222:"
"00000:"
"00000:")
rotat8 = Image("00000:"
"00002:"
"02220:"
"20000:"
"00000:")
rotat9 = Image("00000:"
"00022:"
"00200:"
"22000:"
"00000:")
rotat10 = Image("00002:"
"00020:"
"00200:"
"02000:"
"20000:")
rotat11 = Image("00020:"
"00020:"
"00200:"
"02000:"
"02000:")
rotat12 = Image("00020:"
"00200:"
"00200:"
"00200:"
"02000:")
accelerometer.set_range(2)
radio.on()
radio.config(group=24, power=3)
while True:
x_val = accelerometer.get_x()
if reversed:
temp_x_val = 0 - x_val
else:
temp_x_val = x_val
if temp_x_val/1000 < -6.5/7: # These if statements show a rotated line on the microbit screen that should appear flat with the rotation, just as a basic indicator
display.show(rotat90)
elif temp_x_val/1000 < -6/7:
display.show(rotat2)
elif temp_x_val/1000 < -5.5/7:
display.show(rotat3)
elif temp_x_val/1000 < -4.5/7:
display.show(rotat4)
elif temp_x_val/1000 < -2.5/7:
display.show(rotat5)
elif temp_x_val/1000 < -1.5/7:
display.show(rotat6)
elif temp_x_val/1000 < 1.5/7:
display.show(rotatflat)
elif temp_x_val/1000 < 2.5/7:
display.show(rotat8)
elif temp_x_val/1000 < 4/7:
display.show(rotat9)
elif temp_x_val/1000 < 5.5/7:
display.show(rotat10)
elif temp_x_val/1000 < 6/7:
display.show(rotat11)
elif temp_x_val/1000 < 6.5/7:
display.show(rotat12)
else:
display.show(rotat90)
print(x_val, x_val / 1000 * 7)
radio.send(str(x_val))