GoalTrace a micro:bit radio program with a variable and an if, run a what-if on a model, and use inverse operations for goal seek.
New words
radio group · the number that decides which micro:bits can hear each otherwhat-if analysis · changing one input of a model to see how the results changegoal seek · choosing the result you want and working backwards to find the input that gives itsimulator · a program that copies a real situation so people can try it safely
Explanation
A micro:bit only hears messages from other micro:bits in the same radio group. The receiver’s on radio received block runs once for every message, and receivedNumber holds the number that arrived. A variable such as count remembers a value between messages, and if … else lets the receiver decide what to show. A model is a simplified copy of a real situation, kept in a program or a spreadsheet. A simulator uses a model so that people can practise or test ideas without risk. What-if analysis changes one input and checks the results again. Goal seek works backwards: you choose the result you want, and use an inverse operation, such as dividing instead of multiplying, to find the input that gives it. A model is only as good as the facts that went into it, so its answer may not match the real world.
Change one inputso→Formulas recalculatethen→Read the new resultand→Compare
Worked examples
A door alert. The door micro:bit sends 1 every time it is shaken. The hall micro:bit starts count at 0, adds 1 for each message and shows the number while count is 2 or less, but a sad icon after that. After four shakes it shows 1, then 2, then the sad icon, then the sad icon again.
A savings model in pseudocode. Every week 5 is added and the spending is subtracted, for three weeks, starting at 20. With spend 2 the output is 29. Running it with other spend values is a what-if test: spend 4 gives 23 and spend 6 gives 17, so each extra 1 of weekly spending takes 3 off the final balance.
D2fx=B2*C2
A
B
C
D
1
Item
Price ($)
Number
Cost ($)
2
Snack
1.5
40
60
3
Drink
0.8
40
32
4
Total
92
A trip sheet. The cost formula is Price × Number, and the total adds the two costs. What if the snack price rose to 1.75? Only the snack cost changes: 1.75 × 40 = 70, and the total becomes 70 + 32 = 102. Goal seek works the other way. To make the snack cost 90 by changing the number, divide: 90 ÷ 1.5 = 60.
Class activity
Message relay (no computer). Three players act out the door alert. Player 1 is the door: each tap on the table is one shake, and they say “1” aloud. Player 2 is the hall and keeps a count on paper. Player 3 is the display and says Number or Sad aloud according to the rule: the number if the count is 2 or less, sad if more. Run 6 taps, then change the rule to count > 3 and run again. Then play what-if with a shopping list: write the total, change one price, and say which numbers need to be recalculated. If you have a computer or tablet, an adult can help you build the savings model in a spreadsheet.
Practice
1
A second hall program adds 2 to count for each message (the door still sends 1) and shows the sad icon when count > 4. Trace four shakes. What changes if the test is count >= 4?
With count > 4: the counts are 2, 4, 6, 8, so the hall shows 2, 4, sad, sad. With count >= 4: it shows 2, sad, sad, sad. The boundary value 4 now gives the sad icon, so one test makes a difference.
2
Run this savings model for spend = 3. What is the output? Then predict the output for spend = 8 without tracing it again.
Each week the balance changes by 8 − 3 = 5, so after two weeks it is 10 + 10 = 20. For spend = 8 each week changes by 0, so the balance stays 10.
3
In the trip sheet the drink price falls to 0.60. Which cells change, and what is the new total? Which cell does not change?
D3fx=B3*C3
A
B
C
D
1
Item
Price ($)
Number
Cost ($)
2
Snack
1.5
40
60
3
Drink
0.6
40
?
4
Total
?
The drink cost D3 changes to 0.60 × 40 = 24, so the total D4 becomes 60 + 24 = 84. The snack cost D2 does not change.
4
The goal is a drink cost of 20 by changing the number of drinks. Fill in the three goal seek items and work out the answer by hand. Why might the model’s answer still not be right for real life?
Set cell: D3. To value: 20. By changing cell: C3. The answer is 20 ÷ 0.8 = 25 drinks. In real life the number of pupils may not match, prices may change, and some people may not want a drink, so the model must be checked.