Skip to content


Secure messaging

Intermediate | MakeCode | Buttons, LED display, Radio | Abstraction, Communication, Encryption, Input/output, Selection

Step 1: Make it

What is it?

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:

How it works

  • 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.

What you need

Secure messaging planning sheet

Secure messaging planning sheet

Step 2: Code it

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)

Step 3: Improve it

  • 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.