Added simple radio test
[microbit.git] / radio_test / radio_send.py
1 from microbit import *
2 import radio
3
4 A_IMAGE = Image('09909:'
5 '90090:'
6 '99990:'
7 '90090:'
8 '90090')
9
10 B_IMAGE = Image('99909:'
11 '90090:'
12 '99900:'
13 '90090:'
14 '99900')
15
16 display.scroll('Press', wait=False, loop=True)
17 last_sent_time = None
18
19 while True:
20 if button_a.was_pressed():
21 display_image = A_IMAGE
22 last_sent_time = running_time()
23 radio.on()
24 radio.send('a')
25 radio.off()
26 if button_b.was_pressed():
27 display_image = B_IMAGE
28 last_sent_time = running_time()
29 radio.on()
30 radio.send('b')
31 radio.off()
32 if last_sent_time:
33 dimness = (running_time() - last_sent_time) / 500
34 if dimness > 9: dimness = 9
35 display.show(display_image / dimness, wait=False)
36