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

Inputs and outputs

Week 19 · Unit 8: Be an innovator · 3 lessons
3

Build it with blocks

Computing 4: Unit 8, pp. 104–122
GoalSay which group each micro:bit block comes from and build a program in the right order.
New words
block editor · a free program for making micro:bit programs by joining blocksblock group · a set of blocks of the same kind, such as Input, Basic or Loopsdownload · to send a finished program from the computer to the board
Explanation

In a micro:bit block editor you build programs by joining blocks. Blocks are kept in groups. The Input group has blocks for buttons, shaking and the logo. The Basic group has show icon, show leds, show number, pause and clear screen. The Loops group has repeat. The Music group has play sound. The Led group has set brightness, and the Math group has pick random. A new project already has two blocks, on start and forever. Delete them if you do not need them. Build the program one block at a time and test it in the simulator. An adult can help to download it to the real board.

BlockGroup
on button A pressedInput
repeat (6) timesLoops
show ledsBasic
pause (ms)Basic
clear screenBasic
play sound until doneMusic
Worked examples
show ledspause (ms)500clear screenpause (ms)500repeat6timeson buttonApressed
The turn-left algorithm from last week as micro:bit blocks. The button block is the input, so it goes first. The repeat block goes inside it, and the show, pause and clear blocks go inside the repeat block. A pause of 500 ms is half a second.
OrderGroupBlock
1Inputon button A pressed
2Loopsrepeat (6) times
3Basicshow leds (draw the arrow)
4Basicpause (ms) 500
5Basicclear screen
6Basicpause (ms) 500
Build the program in this order. Test it in the simulator after the last block: press A and count 6 flashes.
BlockGroup
on shakeInput
show numberBasic
show stringBasic
pick random 1 to 6Math
set brightnessLed
Other useful blocks and where to find them.
Class activity

Block cards (with family): write each block on a small card: on button B pressed, repeat 3 times, show leds (square), pause 2000 ms, clear screen, pause 1000 ms. Mix them up. Another person puts the cards in the right order to make the stop program from last week. Read the program out loud as an algorithm. Then change it so that the square flashes 5 times with button A. Which cards did you have to change?

Practice
1
Which group does each block come from: A on shake, B pause, C repeat, D play sound?
BlockGroup
A on shake?
B pause?
C repeat?
D play sound?
2
Put these blocks in the order that you would add them to the project: A show icon, B on button B pressed, C clear screen, D repeat (2) times.
3
What happens when button B is pressed? How many seconds of waiting are there in all?
show iconnopause (ms)1000clear screenrepeat2timeson buttonBpressed
4
Your program does not do what you expected in the simulator. What should you do?