Week 6 · Unit 7.2: Decomposing problems · 3 lessons
2
Practise before the real thing
Computing 7: Unit 7.2, pp. 44–81
GoalExplain what a simulator is, and name the inputs and outputs of a micro:bit.
New words
simulator · software that behaves like a real system so that you can practise or test safelymicro:bit · a small programmable board with lights, buttons and sensorssensor · a part that measures something in its surroundings, such as light or movementsmart device · a device that uses sensors to collect data and a program to decide what to do
Explanation
A simulator is software that behaves like a real system, so you can practise or test without any danger. Engineers use simulators to test a bridge design, and forecasters use them to see how a river might flood. A mistake in a simulator costs nothing. The micro:bit is a small programmable board, a physical computing device. Its inputs include buttons A and B, a touch logo, a light sensor, a temperature sensor, a microphone and an accelerometer, which senses movement. Its outputs are the 25 lights and a buzzer, which makes sound. A smart device uses sensors to collect data, and its program decides what the output should be. The block editor for the micro:bit has a simulator, so you can test a program before you put it on the real board.
Inputs (data goes in)
Outputs (results come out)
buttons A and B
the 25 lights
touch logo, microphone
the buzzer (sound)
light, temperature and movement sensors
(none: a sensor only sends data in)
Worked examples
rainfall numbers→river simulator→predicted river height
A town planner wants to know what happens if the river rises by a metre. She does not wait for a flood. She puts the rainfall numbers into a river simulator and reads the predicted heights. The simulator is safe, quick and can be run again with new numbers.
door sensor→program decides→speaker plays tune
A shop has a smart door chime. A sensor notices that someone has come in (input). The program decides that a visitor has arrived (process). The speaker plays a short tune (output). Every smart device follows this pattern: input, process, output.
The micro:bit’s lights are in 5 rows and 5 columns. Each light is on (1) or off (0). This board has the outer ring of lights on and the middle off. We can write the rows as 11111, 10001, 10001, 10001, 11111.
Class activity
Paper micro:bit (no computer). Draw a 5 × 5 grid on squared paper and two buttons, A and B. A friend is the program and holds a rule card, for example: “If A is pressed, colour the middle row.” You press A by tapping the paper button, and your friend colours the lights. Then swap roles and make a new rule with a different pattern for B. Write down the inputs and outputs you used. If you have a computer or tablet, an adult can show you a micro:bit simulator.
Practice
1
Sort into inputs and outputs: button B, buzzer, temperature sensor, the 25 lights, microphone, touch logo.
Part
Input or output?
button B
?
buzzer
?
temperature sensor
?
25 lights
?
microphone
?
touch logo
?
Inputs: button B, temperature sensor, microphone, touch logo. Outputs: buzzer, the 25 lights.
2
Give two reasons why a simulator is useful before building the real thing.
Any two of: it is safe; it costs less; mistakes can be fixed before anything real is made; it can be run again and again with different numbers; it saves time.
3
A fridge beeps if its door stays open for too long. What kind of sensor does the fridge need? What is the output?
?→program decides→beep
It needs a sensor that notices the door is open (a door-open or touch-contact sensor). The output is the beep.
4
Write the five rows of 1s and 0s for the lights on this board.