Week 10 · Unit 7.2: Decomposing problems · 3 lessons
3
Project: bedtime pal
Computing 7: Unit 7.2, pp. 44–81
GoalPlan, make, test and evaluate a small micro:bit project on paper, with two inputs and two outputs.
New words
input · data that goes into the device, such as a sensor reading or a button pressoutput · what the device shows or playsprototype · a first working model of a device, built to test an ideaevaluation · a careful judgement of how well a finished program meets its success criteria
Explanation
In this lesson you will take one small project through all five stages on paper. The problem: a younger child needs a bedtime pal that shows a sleeping face when the room is dark, shows a smile when it is light, and plays a gentle tune when button A is pressed. The device has two inputs, the light sensor and button A, and two kinds of output, a picture and a tune. Plan the success criteria first. Then draw the flowchart, write the program, test it with a test plan that includes the values around the threshold, and finally evaluate it with a user. A first model like this is a prototype, and the evaluation tells you how to improve it.
Stage
Bedtime pal
plan
success criteria: sleeping face when the light level is below 40; smile otherwise; tune when A is pressed
design
flowchart with two decisions
create
MicroPython program
test
test plan with values 5, 39, 40, 200
evaluate
ask a child what they think; list improvements
Worked examples
This is the design. There are two decisions, one after the other. The first checks the light, the second checks button A.
light below 40: sleeping face; otherwise a smile; A pressed: a tune
This is the program for the flowchart. Everything is inside while True, so the pal keeps checking the light and the button.
Test
Test data
Expected outcome
Actual outcome
Pass/fail
1
light 5, A not pressed
sleeping face, no tune
sleeping face, no tune
pass
2
light 40, A not pressed
smile, no tune
smile, no tune
pass
3
light 39, A not pressed
sleeping face, no tune
sleeping face, no tune
pass
4
light 200, A pressed
smile and tune
smile and tune
pass
5
light 5, A pressed
sleeping face and tune
sleeping face and tune
pass
This is the test plan. The expected outcomes were worked out from the flowchart before the program was run. Test 2 uses the threshold itself, and 40 is not below 40.
Class activity
Your own project (no computer). Invent a small device with two inputs and two outputs, for example a plant reminder that uses the light sensor and button B, or a toy that uses a gesture and the temperature. Write the success criteria, draw the flowchart, write the program, make a test plan with at least five tests (including a value on the threshold) and fill in the expected outcomes. Trace your program to find the actual outcomes. Then ask a friend or family member to be the user and write down three improvements. If you have a micro:bit and an adult to help, test the real device.
Practice
1
Write three success criteria for a bedtime pal.
Model answer: it shows a sleeping face when the light level is below 40; it shows a smile when the light level is 40 or more; it plays a tune when button A is pressed; the pictures and the tune are gentle and clear for a young child.
2
Complete the expected outcomes for these new tests of the bedtime pal.
Test
Test data
Expected outcome
6
light 100, A not pressed
?
7
light 41, A pressed
?
8
light 0, A not pressed
?
Test 6: smile, no tune. Test 7: smile and tune. Test 8: sleeping face, no tune.
3
Use the feedback from the child tester to write two improvements for the bedtime pal.
Question
Child’s answer
Was the picture friendly?
The sleeping face was good, but the smile woke me up.
Was the tune right?
It was too long and I fell asleep before the end.
Was it easy to use?
I could press A by myself.
Model answer: (1) choose a shorter, quieter tune, or only play it once; (2) show a clearer picture for the daytime, for example a different friendly picture, and test the changes again with the same test plan.
4
A classmate says the bedtime pal does not need a test plan because “I can see that it works”. Explain why a test plan is still useful.
A test plan checks values you might not try by chance, such as the value exactly on the threshold. It records expected and actual outcomes, so a bug cannot be missed or forgotten, and anyone can repeat the tests.