One-sentence summary
Two micro:bits can send each other messages and numbers over radio waves with no cable at all, and in this lesson we build a small system where pressing a button on one board makes an icon appear on the other.
Why does it matter?
Every program you have written so far ran on a single micro:bit. The board read its own buttons and wrote to its own screen. But most real devices do not work alone. A phone talks to a cell tower, a remote talks to a toy car, a weather station talks to the display indoors.
Inside the micro:bit there is a small radio. A radio is a component that lets a board send and receive messages without any wire. When you set two boards to the same group, one can hear the other.
This lets you build your first system where more than one device works together: a wireless doorbell, a signal between two players, or a tiny network that carries temperature from one room to another.
How does the radio work?
The idea of a group
In a classroom, ten micro:bits might all be sending messages at once. So how does your board know which one to listen to? The radio group solves this.
A radio group is a number between 0 and 255. Only boards in the same group hear each other. Messages from other groups are ignored. Think of it like a walkie-talkie channel: if two people want to talk, they must switch to the same channel.
Short definition: A radio group is a channel number that lets micro:bits sharing the same number hear one another.
If you and your friend set your boards to group 7, the group 3 boards at the next desk will not receive your messages. This prevents confusion in a crowded classroom.
The send and receive events
Radio has two basic jobs:
- Send: A board sends out a number, some text, or a signal.
- Receive: Another board catches that message and does something.
To receive, instead of waiting inside "forever" we use an event. The "on radio received" event runs at the exact moment a message arrives. That way the board does not waste time waiting; it reacts when the message comes.
Example 1: Press a button, a heart appears over there
Goal: When you press button A on board A, a heart icon appears on the screen of board B.
MakeCode block sequence (sending board)
on start
set radio group to 7
forever
if <button A is pressed> then
radio send number 1
MakeCode block sequence (receiving board)
on start
set radio group to 7
on radio received (receivedNumber)
if <receivedNumber = 1> then
show icon heart
pause 500 ms
clear screen
Notice that both boards are set to group 7. The sending board sends the number "1". The receiving board shows the heart if the number it gets is 1. You can flash each board with a separate program, or put both the sending and receiving blocks together in a single program.
The same idea in MicroPython
Sending board:
from microbit import *
import radio
radio.on()
radio.config(group=7)
while True:
if button_a.was_pressed():
radio.send("1")
Receiving board:
from microbit import *
import radio
radio.on()
radio.config(group=7)
while True:
message = radio.receive()
if message == "1":
display.show(Image.HEART)
sleep(500)
display.clear()
Blocks and Python look different, but the logic is the same: same group, send, receive, compare, show.
Example 2: A two-way signal
Now let both boards send and receive. Pressing button A on board A shows an up arrow on board B; pressing button B on board B shows a down arrow on board A.
A single program flashed onto both boards:
on start
set radio group to 3
forever
if <button A is pressed> then
radio send string "up"
if <button B is pressed> then
radio send string "down"
on radio received (message)
if <message = "up"> then
show arrow up
else if <message = "down"> then
show arrow down
Here one file runs on both boards. A message sent by one board is received and shown by the other as an arrow. Systems that work this way are called peer to peer: both can speak and both can listen.
Two everyday examples:
- Two people on walkie-talkies: while one talks, the other listens, then they swap. The micro:bits do this very quickly, taking turns.
- A doorbell and its receiver: the button at the door sends a signal, and the device inside makes a sound or light. In our example the signal becomes a heart or an arrow.
Mini practice
Build a wireless rock-paper-scissors signal with a friend.
Task:
- Set both micro:bits to the same group (for example, group 12).
- When A is pressed, send the text "rock" and show
Ron your own screen. - When B is pressed, send the text "paper" and show
Pon your own screen. - When a radio string arrives, show the received choice on screen for a short time.
Starting block:
on start
set radio group to 12
forever
if <button A is pressed> then
show string "R"
radio send string "rock"
Ask yourself:
- What happens if the two boards are in different groups? (No message is received.)
- If you both press at the same time, can each board show both its own choice and the choice it receives?
Common mistakes
Setting the groups differently
This is the most common mistake. If one board is on group 7 and the other on group 1, the message never arrives. Always make sure both boards are set to the same group number in "on start".
Forgetting to turn the radio on (MicroPython)
In Python, if you do not write radio.on(), the radio stays off and nothing is sent. In MakeCode, using a radio block turns it on automatically; in Python, turning it on is up to you.
Mixing up numbers and text
A message sent with radio send number is only caught by "on radio received (number)", while radio send string is caught by "on radio received (string)". The type you send must match the type you receive.
Never clearing the screen
If you show the heart but never clear the screen, the old image stays when the next message arrives and things get confusing. Adding clear screen after a short pause fixes it.
Safety note
- When you power the micro:bit from a battery pack, make sure the batteries go in with the correct polarity (+/–), and check this with an adult. Use only low-voltage AAA batteries.
- If you attach the board to a bag, bike, or piece of clothing to make a portable signal, fix it firmly so the cables cannot be caught and pulled loose.
- During cycling or a similar activity, the device must not distract you; do not look at the screen while riding, and keep your attention on the road.
Lesson summary
- The radio inside the micro:bit sends and receives messages and numbers with no cable.
- The radio group (0–255) works like a channel; only boards in the same group hear each other.
- "Send" delivers a message; the "on radio received" event runs when a message arrives.
- Numbers and text are separate types; the type you send must match the type you receive.
- Two boards can both send and receive to build a peer-to-peer system.
Check questions
- What does the radio group do, and what number range does it use?
- Which setting must be the same for two micro:bits to hear each other?
- Why is using the "on radio received" event better than waiting inside "forever"?
- Which block receives a message sent with
radio send number 1? - In MicroPython, which command must you call before using the radio?
Answers
- The radio group is a channel number that decides which boards hear each other; it ranges from 0 to 255. Only boards in the same group receive each other's messages.
- The radio group number must be the same. Boards in different groups do not hear each other.
- The event runs only at the moment a message arrives; instead of waiting for nothing, the board reacts as soon as a message comes. This keeps the code tidier and more efficient.
- You receive it with the "on radio received (number)" block. A message sent as a number is only caught by the number-receiving block.
- You must call
radio.on(). You also set the group withradio.config(group=...).
Source and verification note
For “Radio Communication”, verification focuses on whether the relationship between How does the radio work? and The send and receive events remains consistent across examples. MakeCode and MicroPython names can vary slightly by version. Test in the simulator first; when external components are connected, check the board’s pin and voltage limits separately.
Next lesson
Pins and External Components: Using the pins on the edge of the micro:bit to connect to the outside world, building small circuits with buttons, LEDs, and crocodile-clip wires.