Skip to content

crwdns342183:0crwdne342183:0

crwdns355800:0crwdne355800:0

crwdns338145:0crwdne338145:0 | MakeCode | crwdns255558:0crwdne255558:0, crwdns255566:0crwdne255566:0, crwdns255570:0crwdne255570:0 | crwdns258504:0crwdne258504:0, crwdns258554:0crwdne258554:0, crwdns258566:0crwdne258566:0, crwdns258616:0crwdne258616:0, crwdns354331:0crwdne354331:0

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

crwdns355778:0crwdne355778:0

crwdns355780:0crwdne355780: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