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

Show it and count it

Week 20 · Unit 8: Be an innovator · 3 lessons
2

Numbers, words and pictures

Computing 5: Unit 8, pp. 104–118
GoalChoose between show number, show string, show icon and show leds, and trace a program that uses pause and clear screen.
New words
show number · an output block that displays a number, such as the value of a variableshow string · an output block that displays letters and wordspause (ms) · a block that waits; 1000 milliseconds is 1 secondclear screen · a block that switches every LED off
Explanation

The micro:bit can output in several ways. The show number block displays a number, such as the value of a variable. The show string block displays letters and words, and text with a number in it is a string too. The show icon block displays a ready-made picture, such as a heart. For any other pattern, the show leds block lets you click the LEDs that you want lit, such as the little house in the picture. Long numbers and words scroll across the 5 × 5 display. The pause block waits for a number of milliseconds, and clear screen turns all the lights off. The Math group also has a block that picks random true or false.

show number15show stringHelloshow icondiamondshow ledson buttonApressed
Worked examples
Coinssetcoinsto3on startCoinsshow stringCoinsshow numbercoinspause (ms)2000clear screenon buttonApressed
Coins: the board starts with 3 coins. When button A is pressed it scrolls the word Coins, shows the number of coins for 2 seconds, and then clears the screen.
StepDisplay
show string Coinsthe word Coins scrolls past
show number coins3
pause 20003 stays for 2 seconds
clear screenall lights off
The trace shows what the display does in each step.
We need to showBlockWhy
the number 24show numberit is only a number
the word Goshow stringit is letters
Room 5show stringit has letters in it
a smiling faceshow iconthere is a ready-made smile
Choose the block that matches what we need to show.
Class activity

Human display (groups). Mark a 5 × 5 grid on the floor with tape or chalk. A leader calls ‘show number 7’ or ‘show string Hi’ and the rest of the group stand on squares to draw it, one character at a time. Then the leader calls ‘pause’ and everyone freezes, and ‘clear screen’ and everyone steps off. Try to show a letter T with as few squares as you can.

Practice
1
Which output block is best for each? (a) the number of goals, 4, (b) the word ‘Goal!’, (c) a heart, (d) the text ‘Team 2’
2
Ana wants the number to stay on the display for 3 seconds before the screen clears. What number should she put in the pause block?
Anashow number7pause (ms)3clear screenon buttonApressed
3
Which block makes this pattern, and where is it found?
ABthe pattern
4
A variable flag is set with ‘pick random true or false’. How many different values can flag hold? What are they?