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

Term 3 round-up

Week 30 · Review: Term 3 · 3 lessons
3

Review: lights and prototypes

Computing 7: Units 7.5–7.6, pp. 150–224
GoalWrite and check light-grid programs, use a sub-routine in a plan and tell the kinds of prototype apart.
New words
pattern recognition · spotting what repeats or stays the same, so that code can be copied and editedevolutionary prototype · a first version that is improved again and again until it becomes the final productthrowaway prototype · a rough version made to answer a question and then thrown awaybrightness · a number from 0 (off) to 9 (full) that sets how brightly a light shines
Explanation

A picture on the 5 × 5 lights is written as five rows of five digits, with a colon after every row except the last. A 9 is a bright light, a 0 is off and the numbers between give less brightness. A sequence is a list of pictures with sleep() between them, and sleep(1000) is one second. display.clear() switches the lights off at the end. Spotting a pattern lets you copy a block of code and change only the parts that differ. A sub-routine is drawn as a box in the main flowchart, and its own flowchart shows the steps. Before the final version, a prototype is tested with users and with a test plan, and the project is evaluated. A prototype that is thrown away is called a throwaway prototype, and one that grows into the final product is an evolutionary prototype.

Part of the planQuestion to ask
project planwhat must it do, what are the inputs and the outputs?
grids and flowchartwhat does each image look like, and in what order?
codedoes every row have five digits and every image a sleep()?
test planwhat should happen? (write it before running)
evaluationwhat would users like to change?
Worked examples
Python
1from microbit import *
2display.show(Image(
3    "99999:"
4    "00090:"
5    "00900:"
6    "09000:"
7    "99999"))
Output
the letter Z stays lit
Plan the letter Z. The top row is all on, the bottom row is all on, and one light in each middle row moves one step to the left. Write 9 for a light that is on and 0 for a light that is off. Check that there are five digits in every row and a colon after every row except the last.
StartIs A pressed?yesnorun sub-routine: pulseDisplay a clear screenEnd
A model beacon pulses when A is pressed. The sub-routine pulse shows the centre light at brightness 3, then 6, then 9, with a wait of 0.3 second after each image, and then clears the screen. The main flowchart stays short, and each press uses the sub-routine for 3 × 0.3 = 0.9 seconds.
SituationKind of prototypeWhy
A village hall tests only the booking form of a new website with six visitors and then builds the real formthrowawayonly one part is tested, and the prototype is thrown away
A team gives a school a first working lunch-ordering program and improves it after each month of feedbackevolutionarythe same program grows into the final product
A cardboard model of a bird box to check its sizethrowaway (physical)it answers a question about size and is not kept
Three prototypes sorted by kind. To decide, ask what the makers want to learn and whether the prototype will be kept. In every case users try it, and their feedback is used to improve the product.
Class activity

Light show on paper (no computer): plan a sequence of three images for a model such as a sunrise, a rocket or a bicycle light. Draw each image on its own 5 × 5 grid, using brightness numbers between 0 and 9. Write a flowchart with the waits and then the whole program. Swap with a partner, who traces your code and draws the three pictures from it. Compare the drawings with your grids. Finally write two test plan rows and one improvement that a user might suggest. If you have a computer or tablet, you can try your program in a micro:bit simulator.

Practice
1
How long does the program wait after each image? Which light is on when the program has finished, and at what brightness?
Python
1from microbit import *
2display.show(Image("00000:00000:00300:00000:00000"))
3sleep(300)
4display.show(Image("00000:00000:00600:00000:00000"))
5sleep(600)
6display.show(Image("00000:00000:00900:00000:00000"))
7sleep(300)
2
Write the five rows of code for the picture on the board.
ABletter V
3
The program should show a big X for half a second and then clear the screen, but the picture is wrong. Find the mistake and write the correct line.
Python
1from microbit import *
2display.show(Image("90009:09090:00900:09090:9009"))
3sleep(500)
4display.clear()
4
A sign should do this: when button B is pressed, the board shows Image.ARROW_S (an arrow pointing down) for 2 seconds and then clears the screen. Write the expected outcomes for the test plan.
TestTest dataExpected outcome
1B pressed once?
2no button pressed?
3B held down for several seconds?