-
Notifications
You must be signed in to change notification settings - Fork 5
/
radio_example.py
41 lines (36 loc) · 1.15 KB
/
radio_example.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
from microbit import *
import make_radio
radio = make_radio.MakeRadio(group=1)
radio.off()
radio.on()
while True:
if button_a.is_pressed():
radio.send_number(99.9)
display.scroll('{99.9}')
elif button_b.is_pressed():
name = 'abcdefghi'
number = 77
radio.send_value(name,number)
display.scroll('{' + name + '=' + str(number) + '}')
elif pin8.read_digital():
name = 'abcdefghijklm'
number = -77.7
radio.send_value(name,number)
display.scroll('{' + name + '=' + str(number) + '}')
elif pin16.read_digital():
msg = 'abcdefghijklmonpqrst'
radio.send_string(msg)
display.scroll('{' + msg + '}')
else:
data = radio.receive_packet()
if data is None:
display.show('+')
else:
if type(data) is int or type(data) is float:
display.scroll('[' + str(data) + ']')
elif type(data) is str:
display.scroll('[' + data + ']')
else:
label,value = data
display.scroll( '[' + label + '=' + str(value) + ']')
sleep(100)