GoalDesign shapes on the 5 × 5 display, write them as rows of 1s and 0s and count how many lights each uses.
New words
LED · a tiny light on the boardrow · a line of lights going across the displaycolumn · a line of lights going down the displayshow leds · a block that lights up the pattern we choose on the display
Explanation
The display of a micro:bit has 25 LEDs in 5 rows and 5 columns. A shape is made by switching some of the LEDs on. In the show leds block, every row has five boxes. A filled box is a light that is on. We can also write a shape as five rows of five digits: 1 means on and 0 means off. A smile, for example, is 00000, 01010, 00000, 10001, 01110. To find how many lights a shape uses, count the 1s. Plan a shape on squared paper first. Then copy it into the show leds block.
Worked examples
This small diamond is written as the rows 00000, 00100, 01010, 00100 and 00000. Count the 1s: 0 + 1 + 2 + 1 + 0 = 4 lights.
A bigger diamond is only a ring of lights. Its rows are 00100, 01010, 10001, 01010 and 00100. The count is 1 + 2 + 2 + 2 + 1 = 8 lights.
A triangle. Its rows are 00100, 01010, 10001, 11111 and 00000. The count is 1 + 2 + 2 + 5 + 0 = 10 lights. The last row is all off, so the triangle sits at the top of the display. We could move it by changing which rows are on.
Class activity
Light designer (with family): draw five squares of 5 × 5 on squared paper. Colour in the boxes to make a shape in each one, such as a letter, an arrow, a house or a tree. Write each shape as five rows of 1s and 0s, and count the lights. Swap your row codes with a partner. Can they draw your shapes from the code only? Which shape uses the fewest lights? Which uses the most?
Practice
1
How many lights are on in this letter E?
16. The rows have 5 + 1 + 4 + 1 + 5 = 16 lights.
2
Write the five rows for a solid rectangle, 3 lights wide and 4 lights high, in the top left corner of the display. How many lights does it use?
The picture shows an arrow that points up. Row 3 is hidden. Work out the missing row.
10101. The arrow has the rows 00100, 01110, 10101, 00100 and 00100.
4
A small plus needs only 5 lights: one in the middle and four around it. The big plus from the lesson uses 9. How many fewer lights does the small plus use?
9 − 5 = 4 fewer lights. The small plus is 00000, 00100, 01110, 00100, 00000.