Skip to content


Secure messaging

中级 | MakeCode | LED显示器, 按钮, 无线电 | 加密, 抽象, 输入/输出, 选择, 通信

第 1 步:制作


Send coded BBC micro:bit radio messages to tell someone how you’re feeling.

These two videos show you what you'll make and how to program it:


  • Press different button inputs on your micro:bit to send different messages over radio to another micro:bit to tell someone how you’re feeling. The output on the receiver micro:bit is either a happy, sad or excited emoji on the LED display.
  • Make sure you and your partner use a unique radio group so that you can send your message to a particular micro:bit or a particular person who has that micro:bit.
  • The program uses a simple kind of code, or encryption. This could stop, for example, another person from reading your messages, and keep them secure.
  • The code used is a simple number cipher. This is a kind of encryption. In this example, 17 means happy, 23 means sad, and 42 means excited. Note - only numbers or letters can be sent by radio and not emojis.
  • Agreeing a unique radio group, a set of possible messages, and a way of encrypting those messages with a partner means you have agreed a protocol, or rules for communicating and keeping your messages secure. Use this sheet to plan your own messaging protocol.
  • The same code goes on both micro:bits, so you and your partner can communicate with each other.


Secure messaging planning sheet

Secure messaging planning sheet

第 2 步:编程

1from microbit import *
2import radio
4# The Python version of this project has sleep()
5# for each button press to make the A+B button work better
10while True:
11    if button_a.is_pressed() and button_b.is_pressed():
13        radio.send('42')
14        sleep(300)
15        display.clear()        
16    elif button_a.is_pressed():
18        radio.send('17')
19        sleep(300)
20        display.clear()
21    elif button_b.is_pressed():
23        radio.send('23')
24        sleep(300)
25        display.clear()
27    message = radio.receive()
28    if message:
29        if message == '17':
31        elif message == '23':
33        else:
35        sleep(2000)
36    display.clear()
37    sleep(200)


  • Customise the emojis to send different messages.
  • Use more of the micro:bit’s physical inputs such as the shake gesture or the touch logo on the micro:bit V2 to send even more messages.
  • Show scrolling text, such as the words 'hot', 'cold' and 'warm', instead of emojis to play a hide and seek game.