← Secret messages

Everyone in the group hears

A radio group is a channel, not a lock. Every micro:bit in the group hears every message, so anything sent in plain text is public to the group.

A school bus radio, a walkie-talkie, a baby monitor: if your radio is on the same channel, you hear it. That is how radio works, and it is why secret messages need more than a channel number.

Radio is how micro:bits talk without a cable. Each one is set to a radio group (a number from 0 to 255). A micro:bit sends to every other micro:bit in its group and to nobody outside it.

This course is about a question that follows: if a message goes out to everyone in the group, how can any of it be private? You will build the answers: secret codes, a way to share a key, a way to spot a changed message, and a way to prove who sent it.

PredictRead the code and say what it will do before you run anything. A wrong guess is fine: it shows you what to look for.

Predict

The program as blocks
Show as code
radio.ts
radio.setGroup(5)
input.onButtonPressed(Button.A, function () {
    radio.sendString("MEET AT 3")
})
radio.onReceivedString(function (receivedString) {
    basic.showString(receivedString)
})
Four micro:bits are switched on: three in group 5 and one in group 6. A is pressed on one micro:bit in group 5. How many micro:bits show MEET AT 3?

RunRun it and compare the result with your prediction.

Run

The simulator runs the program on two micro:bits. Press A on one and watch the other.

The program as blocks
Show as code
radio.ts
radio.setGroup(5)
input.onButtonPressed(Button.A, function () {
    radio.sendString("MEET AT 3")
})
radio.onReceivedString(function (receivedString) {
    basic.showString(receivedString)
})
Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.

InvestigateTrace how each line of code connects to what you see.

Investigate

The program as blocks
Show as code
radio.ts
radio.setGroup(5)
input.onButtonPressed(Button.A, function () {
    radio.sendString("MEET AT 3")
})
radio.onReceivedString(function (receivedString) {
    basic.showString(receivedString)
})
Mia says: 'Group 99 keeps our messages private, because nobody knows the number.' Is she right?

Match each block with what it does.

radio set group 5
radio send string
on radio received string

Who hears a message sent from a micro:bit in group 5?

Another micro:bit in group 5, across the room
A micro:bit in group 6
A micro:bit in group 5 in the next classroom
The micro:bit that sent it

ModifyChange the code on purpose and check the result.

Modify

Make B send a second message of your own. Every micro:bit in the group would read it.

Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.
Need a hint?

Copy the A block, change it to Button B and change the text.

A sends one message and B sends a different one.

This ticks by itself when your blocks do what is asked.

MakeBuild something new using what you have learned. Expect a few tries; that is normal.

Make

Make a doorbell. Pressing A on one micro:bit sends RING; the other shows an icon and plays a tone. You will meet this doorbell again: by the end of the course it will be a lock that is hard to fool.

Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.
Need a hint?

Pressing A sends the word RING.

Another hint

On radio received string: if the text is RING, show an icon and play a tone.

A doorbell: A sends RING; a micro:bit that receives RING shows an icon and plays a tone.

This ticks by itself when your blocks do what is asked.

For teachers

Students learn that a radio group is a shared channel, so plain-text radio messages are public to everyone in the group. About 40 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

The idea: radio goes to everyone. A radio group is a channel number; it decides who is listening, not who is allowed to listen. Anything sent in plain text can be read by any micro:bit set to that group.

Why start here: the whole course answers one question: if everyone in the group hears everything, how do we keep a message private, know it was not changed, and know who sent it? Students should leave this lesson feeling that question is real.

Hardware: the course works in the simulator throughout. Real micro:bits make it better: give every pair its own group and write the numbers on the board.

Running the lesson

  1. Predict: most say 3 or 4. Ask: does the sender hear itself? Is group 6 listening?
  2. Investigate: Mia's 'secret' group is the key misconception. Ask what a stranger would have to do to hear it.

The hard part (on purpose)

A group number is a channel, not a lock. Ask who else can hear the message before they assume it is private.

When students get stuck

Stretch and support

Stretch: Add a third micro:bit in the same group and see that both hear A's message.

Support: Give the doorbell with the receiving part complete.

Where it leads

Next: hide the message from anyone who is listening, starting with a simple scrambling method.

What each step is for

Now you can
Next lesson2. Scrambling is not a secretA scrambling method works only while nobody knows the method. A real code has a public method and a secret key.