Light show project
Answers are for parents and teachers.
1
Write the program lines for a sequence of three images: all the lights in row 1 on at 9, then all the lights in row 3 on at 9, then all the lights in row 5 on at 9. Use 300 milliseconds for each wait and clear the screen at the end.
from microbit import *, then display.show(Image("99999:00000:00000:00000:00000")), sleep(300), display.show(Image("00000:00000:99999:00000:00000")), sleep(300), display.show(Image("00000:00000:00000:00000:99999")), sleep(300), display.clear().
2
A light shines at brightness 2, then 5, then 9, then goes off. Write the first row of each image if the light is the centre light of row 1.
Image 1 row 1: 00200. Image 2 row 1: 00500. Image 3 row 1: 00900. Image 4 row 1: 00000 (and the other rows are all 0).
3
Copy the table and put the lines in the right order for a program that shows a heart for 1 second, then a small heart for 2 seconds, and then clears. Write the letters in order.
| Letter | Line |
|---|---|
| A | sleep(1000) |
| B | from microbit import * |
| C | display.clear() |
| D | display.show(Image.HEART_SMALL) |
| E | display.show(Image.HEART) |
| F | sleep(2000) |
B, E, A, D, F, C. First the import line (B), then the heart (E) and its wait of 1000 milliseconds (A), then the small heart (D) and its wait of 2000 milliseconds (F), and last the clear line (C).
4
Look at the flowchart. The sub-routine Blink shows a heart for 0.5 second and then clears the screen. How many times does the lamp blink? Why is a sub-routine useful here?
The lamp blinks twice, once each time the box ‘run sub-routine: Blink’ is reached, with a 1-second pause between the blinks. The sub-routine is written once and used twice, so the flowchart is shorter and a mistake only has to be fixed in one place.
5
What can you do? Write one sentence for each: (a) explain what a prototype is; (b) explain AND, OR and NOT; (c) write a picture on the micro:bit as rows of 0 and 9; (d) explain how a test plan helps.
Model answers: (a) a prototype is a first working model used to test an idea and get feedback. (b) AND needs both inputs true, OR needs one or both, NOT reverses the input. (c) each row is five digits in quotation marks with a colon after every row except the last. (d) a test plan lists test data and expected outcomes, so you can check that the program works and find bugs.