crwdns355728:0crwdne355728:0
crwdns355730:0crwdne355730:0
crwdns355732:0crwdne355732:0
crwdns355734:0crwdne355734:0
crwdns355740:0crwdne355740:0
- crwdns355742:0crwdne355742:0 crwdns355744:0crwdne355744:0
- crwdns355746:0crwdne355746:0
- crwdns355748:0crwdne355748:0 crwdns355750:0crwdne355750:0
- crwdns355752:0crwdne355752:0 crwdns355754:0crwdne355754:0 crwdns355756:0crwdne355756:0 crwdns355758:0crwdne355758:0
- crwdns355760:0crwdne355760:0 crwdns355762:0crwdne355762:0 crwdns355764:0crwdne355764:0
- crwdns355766:0crwdne355766:0
crwdns355768:0crwdne355768:0
- crwdns355770:0crwdne355770:0
- crwdns355772:0crwdne355772:0
- crwdns355774:0crwdne355774:0
- crwdns355776:0crwdne355776:0
crwdns355782:0crwdne355782:0
1from microbit import *
2import radio
3
4# The Python version of this project has sleep()
5# for each button press to make the A+B button work better
6
7radio.config(group=3)
8radio.on()
9
10while True:
11 if button_a.is_pressed() and button_b.is_pressed():
12 display.show(Image.SURPRISED)
13 radio.send('42')
14 sleep(300)
15 display.clear()
16 elif button_a.is_pressed():
17 display.show(Image.HAPPY)
18 radio.send('17')
19 sleep(300)
20 display.clear()
21 elif button_b.is_pressed():
22 display.show(Image.SAD)
23 radio.send('23')
24 sleep(300)
25 display.clear()
26
27 message = radio.receive()
28 if message:
29 if message == '17':
30 display.show(Image.HAPPY)
31 elif message == '23':
32 display.show(Image.SAD)
33 else:
34 display.show(Image.SURPRISED)
35 sleep(2000)
36 display.clear()
37 sleep(200)
crwdns355784:0crwdne355784:0
- crwdns355786:0crwdne355786:0
- crwdns355788:0crwdne355788:0
- crwdns355790:0crwdne355790:0
This content is published under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.