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

Make it, judge it, improve it

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.

StageBedtime pal
plansuccess criteria: sleeping face when the light level is below 40; smile otherwise; tune when A is pressed
designflowchart with two decisions
createMicroPython program
testtest plan with values 5, 39, 40, 200
evaluateask a child what they think; list improvements
Worked examples
Startlight_level = light sensor readinglight_level < 40?yesnoshow a sleeping faceshow a smileA pressed?yesnoplay a tuneEnd
This is the design. There are two decisions, one after the other. The first checks the light, the second checks button A.
Python
1from microbit import *
2import music
3while True:
4    light_level = display.read_light_level()
5    if light_level < 40:
6        display.show(Image.ASLEEP)
7    else:
8        display.show(Image.SMILE)
9    if button_a.is_pressed():
10        music.play(music.PRELUDE)
Output
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.
TestTest dataExpected outcomeActual outcomePass/fail
1light 5, A not pressedsleeping face, no tunesleeping face, no tunepass
2light 40, A not pressedsmile, no tunesmile, no tunepass
3light 39, A not pressedsleeping face, no tunesleeping face, no tunepass
4light 200, A pressedsmile and tunesmile and tunepass
5light 5, A pressedsleeping face and tunesleeping face and tunepass
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.
2
Complete the expected outcomes for these new tests of the bedtime pal.
TestTest dataExpected outcome
6light 100, A not pressed?
7light 41, A pressed?
8light 0, A not pressed?
3
Use the feedback from the child tester to write two improvements for the bedtime pal.
QuestionChild’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.
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.