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

Light show project

Week 29 · Unit 7.6: Sequencing and pattern recognition · 3 lessons
2

Bright and dim

Computing 7: Unit 7.6, pp. 182–224
GoalUse the numbers 1 to 8 to set the brightness of a light, and plan a fading sequence.
New words
brightness · how strongly a light shines; on the micro:bit it is a number from 0 (off) to 9 (full)fade · to change the brightness step by step, for example from dim to brightclear screen · an image where every light is 0, so that all the lights are off
Explanation

Each light on the micro:bit can shine at ten levels. The number 0 means off and 9 means full brightness. The numbers 1 to 8 are in between, and about 4 or 5 is half brightness. In an image, you can use different numbers for different lights to make a glow. To make a fade, show the same shape several times, with a higher number each time. Plan the numbers on a grid first. Then write the code, with a sleep after each image so that the eye can see each step. An image with 0 in every place switches all the lights off, so it can be the last step of a sequence.

NumberHow the light shines
0off
1–2very dim
3–4dim
5about half
6–8bright
9full brightness
Worked examples
RowBright glow
100000
203630
306960
403630
500000
A glow in the middle of the board. The centre is brightest, the lights next to it are medium and the corner lights of the ring are dim. The grid holds the numbers.
StartDisplay the dim glowwait 0.5 secondDisplay the bright glowwait 0.5 secondDisplay all lights offwait 0.5 secondEnd
A fade-in plan. The glow starts dim (numbers 1, 2 and 3), then becomes bright (3, 6 and 9), and finally all the lights go off. The flowchart has the three images with waits.
Python
1from microbit import *
2display.show(Image("00000:01210:02320:01210:00000"))
3sleep(500)
4display.show(Image("00000:03630:06960:03630:00000"))
5sleep(500)
6display.show(Image("00000:00000:00000:00000:00000"))
7sleep(500)
Output
a dim glow, a bright glow, then all lights off
The program for the plan. The shape of the numbers is the same in the first two images; only the brightness changes. The third image is all zeros.
Class activity

Shade the scale (no computer). Draw a 5 × 5 grid on paper and shade the squares with a pencil, from white (0) to very dark (9). Write the numbers inside. Then make a partner’s grid: call out a row such as 03630 and they shade it. Draw the three steps of a candle getting brighter and write the numbers for each step.

Practice
1
The lamp below is shown at full brightness. Write the grid rows for a fade-in sequence of three images: all the lit lights at 3, then at 6, then at 9. How many lights are lit in each image?
ABfull brightness
2
Read this program. Which light is the brightest, how bright is it, and how many lights are on?
Python
1from microbit import *
2display.show(Image(
3    "10000:"
4    "21000:"
5    "32100:"
6    "43210:"
7    "54321"))
3
A fade-in should start dim, then become bright, then switch off. The programmer wrote the images in the wrong order. Describe what the lights do and how to fix the program.
Python
1from microbit import *
2display.show(Image("00000:03630:06960:03630:00000"))
3sleep(500)
4display.show(Image("00000:01210:02320:01210:00000"))
5sleep(500)
6display.show(Image("00000:00000:00000:00000:00000"))
7sleep(500)
4
Give two reasons why controlling brightness is useful in a light display.