One-sentence summary
We make two micro:bits talk over radio, so that pressing a button on one board updates the score shown on the other board wirelessly.
Why it matters
In a basketball game the scoreboard usually sits at the side of the court, and the person keeping score does not hold the scoreboard in their hand. The scorekeeper and the board are often in different places. This lesson does exactly that: one micro:bit becomes the "remote that counts points," and the other becomes the "board on the wall."
Every program you have written so far ran inside a single board. This project connects two devices for the first time. A button pressed on one board changes the display on another board wirelessly. That is a small version of how phones, game controllers and smart-home devices work.
Inside every micro:bit there is a radio. The radio is a wireless way for boards to send each other short messages, just like two walkie-talkies talking on the same channel. In this lesson we will set up the radio, send a message, and show a message that arrives. These three skills are the foundation of every multi-device project that follows.
How the radio works
Group: being on the same channel
For two micro:bits to hear each other, they must be in the same radio group. A group is a number between 0 and 255 and works like a "channel." If everyone in the class uses a different group, the messages do not get mixed up.
Think of it like a walkie-talkie channel: two friends on channel 7 can hear each other; if one is on 7 and the other on 3, they cannot hear each other no matter how loud they shout.
Sender and receiver
There are always two roles on the radio:
- Sender: Sends a message when something happens (a button is pressed).
- Receiver: Shows the message on its display when it arrives.
In this project one board is always the sender and the other is always the receiver. Both must be set to the same group.
Variable: remembering the score
The score is a number, and it should go up by 1 each time the button is pressed. To store this number we use a variable. A variable is a named box that we put a value into and can change later. We will call it score and set it to 0 at the start.
Step by step: build the scoreboard
1. Sender board (the remote)
Here is the logic of the sender board in MakeCode blocks:
on start
set radio group to 7
score = 0
on button A pressed
change score by 1
radio send number: score
show number score
The same program in MicroPython:
from microbit import *
import radio
radio.config(group=7)
radio.on()
score = 0
while True:
if button_a.was_pressed():
score += 1
radio.send(str(score))
display.show(score)
Because radio.send sends text, we turn the number into text with str(score).
2. Receiver board (the board)
The receiver board has only one job: show the message when it arrives.
on start
set radio group to 7
on radio received (receivedNumber)
show number receivedNumber
In MicroPython:
from microbit import *
import radio
radio.config(group=7)
radio.on()
while True:
message = radio.receive()
if message:
display.scroll(message)
radio.receive() returns None when there is no new message, so if message: makes sure we only display a real message when one arrives.
3. Program both boards
You need to load two different programs onto two micro:bits: the sender program on one, the receiver program on the other. Make sure both are on group 7.
Testing: does it really work?
| Test | Condition | Expected behaviour | Observed result | Next decision |
|---|---|---|---|---|
| Normal | Standard input and complete connection | The core task is completed | Fill in during testing | Keep it or make a small improvement |
| Boundary | Lowest or highest accepted value | The system remains stable | Fill in during testing | Review the threshold or rule |
| Failure | Missing, incorrect or unexpected input | A safe and understandable response | Fill in during testing | Add error handling |
| Repeat | At least three trials under the same condition | Similar results | Fill in during testing | Investigate the source of inconsistency |
Writing a project is not enough; you must confirm it by trying different situations. Test these scenarios in order:
- First press: Press A once on the sender board. The receiver should show
1. - Counting: Press A five times in a row. The receiver should climb
1, 2, 3, 4, 5. - Distance: Move the boards a few metres apart and try again. The radio should still work.
- Group separation: Have a friend's board on group 3. Their presses should not change your board.
For each scenario, write down what you expect first, then watch what actually happens. If the two are different, there is a bug.
A bug and its fix
On my first try, the receiver's display never changed. The sender board showed 1, 2, 3, but the board stayed blank.
I compared the expected result with the actual result:
Goal: When the sender presses A, a number appears on the receiver
Problem: The sender counts correctly, but the receiver never reacts
Check: The sender group is 7, the receiver group is set to 1
Fix: Set the receiver group to 7 as well
The problem was that the two boards were on different radio groups. Like two walkie-talkies on different channels, the messages were being sent, but the other side was not listening on that channel. Once both groups were 7, the score appeared instantly.
This bug is very common, and it gives a useful reminder: if a wireless system does not work, first check whether both sides are on the same group.
Improve the project
Once the basic system works, you can move it closer to the rules of basketball:
Two different point values
In basketball a free throw is 1 point and a normal basket is 2 points. Let's add 2 points to button B:
on button A pressed
change score by 1
radio send number: score
on button B pressed
change score by 2
radio send number: score
Reset by shaking
For a new game you want to reset the score. Thanks to the micro:bit's accelerometer, shaking the board can be used as an event:
on shake
score = 0
radio send number: score
This addition shows how the accelerometer you met in earlier modules connects to this project.
Mini practice
Grab two micro:bits with a friend and complete this task:
- Load the sender program on one and the receiver on the other (group 7).
- Let one person keep score while the other watches the board across the room.
- After five presses, check that the board shows the correct number.
- Then add 2 points with button B, and reset by shaking.
Keep a record: Which group number did you use? Did it work on the first try, or did you fix something? These notes stop you from falling into the same mistake on your next project.
Common mistakes
Setting the two boards to different groups
This is the most common mistake. If the sender and receiver are not on the same group, the message never arrives. Make sure the group number is identical in both programs.
Forgetting to turn the radio on
In MicroPython, if you do not write radio.on(), the radio stays off and no message goes anywhere. In MakeCode, placing the radio-group block turns the radio on automatically.
Sending a number without turning it into text
In MicroPython radio.send expects text. Writing radio.send(score) gives an error; you must write radio.send(str(score)).
Resetting the score inside the loop
If you accidentally put score = 0 in the part that runs forever, the score resets on every pass and never goes up. The reset should happen only at the start.
Safety note
- If you run the micro:bit from a battery pack, put the batteries in with an adult and use only the correct low-voltage (AAA) batteries for the board.
- If you attach the boards to your clothing or to a sign, fasten them securely; dangling wires can catch on things.
- The radio is only a low-power, short-range signal; it harms no one, but do not touch the board's metal pins to a wall socket or any other power source.
- When you add reset-by-shaking, make sure there is nothing breakable around you.
Lesson summary
- Two micro:bits can send each other wireless messages when they are set to the same radio group.
- The radio always has a sender role and a receiver role; both must be on the same group.
- We use a variable to store the score, and when a button is pressed we both increase it and send it.
- In MicroPython
radio.sendsends text, so we convert the number withstr();radio.receive()returnsNonewhen there is no message. - If a wireless system does not work, the first thing to check is whether both sides are on the same group.
Check questions
- Which setting must be the same for two micro:bits to hear each other?
- On which event does the sender board send a message, and when does the receiver change its display?
- Why do we write
radio.send(str(score))in MicroPython instead ofradio.send(score)? - If the receiver never reacts but the sender counts correctly, what is the first thing you check?
- Which event block do you add to give 2 points with button B?
Answers
- The radio group must be the same. Boards on different groups cannot hear each other, like walkie-talkies on different channels.
- The sender board sends a message when button A is pressed; the receiver changes its display when a number is received over radio.
- Because
radio.sendexpects text. Sending the number directly gives an error;str(score)turns the number into text. - I check whether the two boards are on the same radio group; this is the most common mistake.
- I add the on button B pressed block; inside it I increase the score by 2 and send the updated score over radio.
Source and verification note
For “Project: Wireless Scoreboard”, verification focuses on whether the relationship between How the radio works and Sender and receiver 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
Project: Bike Safety Light Prototype: We turn the micro:bit into a wearable safety device and design a light system that improves visibility in the dark.