AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Messages without wires

Week 15 · 1.8 Physical computing · 3 lessons
3

Reading the messages

Computing 8: Topic 1.8, pp. 173–196
GoalTrace a receiver that uses a variable and works with messages from two micro:bits.
New words
message · the number or text sent by one micro:bit and received by anotherreceivedNumber · the name that holds the number that has just arrivedtrace table · a table that records what each device sends, stores and shows after each event
Explanation

More than two micro:bits can share one group. Every micro:bit in the group hears every message. A receiver runs its on radio received block once for each message. The value that arrived is in receivedNumber, but only until the next message comes. To keep a running total, the receiver can store it in a variable. For example, change total by receivedNumber adds the new number to total, and then show number total displays the total. The order of events matters. Make a trace table with one row for each event and a column for each micro:bit’s variable or display. A micro:bit in another group is not part of the conversation and shows nothing.

Worked examples
Micro:bit X (group 3)radio set group3on startradio send number2on buttonApressedMicro:bit Y (group 3)radio set group3on startradio send number4on buttonBpressedReceiver (group 3)radio set group3settotalto0on startchangetotalbyreceivedNumbershow numbertotalon radio receivedreceivedNumber
Two senders and one receiver in group 3. X sends 2 when A is pressed. Y sends 4 when B is pressed. The receiver adds each number to total and shows total. Each message is an event.
EventNumber senttotal after the messageReceiver shows
X: press A222
Y: press B466
Y: press B41010
X: press A21212
Tracing the events in order: X presses A, then Y presses B, then Y presses B again, then X presses A. total starts at 0.
Spare micro:bit (group 4)radio set group4on startshow numberreceivedNumberon radio receivedreceivedNumber
A fourth micro:bit uses group 4. It does not hear any of these messages, so it shows nothing. Changing it to group 3 would let it join the conversation.
Class activity

Message relay (no computer). Three players. Two are senders, and each has a card with a number between 1 and 9. One is a receiver who keeps a total on a piece of paper. The senders call out their numbers in a chosen order, and the receiver adds each new number to the total and says the total aloud. A fourth player holds a different group card and must stay silent. Write the trace table for your game: event, number sent, total. Then change one sender’s number and predict the new final total before playing again. If you have a computer or tablet, ask an adult to help you open the block editor and drag in the blocks.

Practice
1
In the program from the lesson, X presses A three times in a row and nothing else happens. What does the receiver show after each press?
2
Complete the trace table. The sender sends 3 when A is pressed and 5 when B is pressed. The events are A, B, B. The receiver adds each number to total.
EventSenttotalReceiver shows
press A3??
press B5??
press B5??
3
A receiver contains set [total] to (0) inside the on radio received block, followed by change total by receivedNumber and show number total. What goes wrong, and how do you fix it?
Receiverradio set group3on startsettotalto0changetotalbyreceivedNumbershow numbertotalon radio receivedreceivedNumber
4
Why is it important to write the events in order in a trace table?