Sensors make decisions
Answers are for parents and teachers.
1
Name three devices that use a sensor. For each one write what the sensor measures and what the output is.
Model answer: an automatic door (sensor notices a person; output: the door opens); a car’s parking sensor (distance; output: a beeping sound); a smart watch (movement; output: a step count).
2
Draw the flowchart for this plan: if the temperature is below 10 degrees, scroll Cold. Otherwise scroll OK.
Start; diamond “temperature < 10?”; yes: parallelogram “scroll Cold”; no: parallelogram “scroll OK”; both paths join at End.
3
Write what the board shows when the light level is 149, 150 and 151.
Python
1from microbit import * 2while True: 3 if display.read_light_level() >= 150: 4 display.show(Image.YES) 5 else: 6 display.show(Image.NO)
At 149: a cross (149 >= 150 is false, so else). At 150: a tick. At 151: a tick.
4
Find the mistake in this program and write the correct line.
Python
1from microbit import * 2while True: 3 if temperature() > 25: 4 display.scroll("Hot") 5 else 6 display.scroll("OK")
Line 5 needs a colon after else: else:
5
A plan says: “warn me when the temperature is 30 or more.” Which operator is correct, > or >=? Explain what happens at exactly 30 degrees with the other one.
The correct operator is >=. With > the warning would not appear at exactly 30 degrees, although the plan says 30 or more.