← micro:bit Foundations

Pictures in order

Show words and pictures on the micro:bit, and see that blocks run once, from top to bottom.

A shop sign scrolls its name, then shows a picture. It is a short list of instructions, done in order.

The micro:bit has 25 small lights (LEDs) in a 5 by 5 grid. You program it with blocks, and the simulator (the picture of a micro:bit next to the blocks) runs your program straight away. No real micro:bit needed.

PredictRead the code and say what it will do before you run anything. A wrong guess is fine: it shows you what to look for.

Predict

The program as blocks
Show as code
lesson.ts
basic.showIcon(IconNames.Heart)
basic.showIcon(IconNames.SmallHeart)

These two blocks sit inside on start. Read them from the top, then lock in your prediction.

What will you see on the micro:bit?

RunRun it and compare the result with your prediction.

Run

The simulator runs the program by itself. Missed it? Press the restart button under the simulator.

The program as blocks
Show as code
lesson.ts
basic.showIcon(IconNames.Heart)
basic.showIcon(IconNames.SmallHeart)
Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.

InvestigateTrace how each line of code connects to what you see.

Investigate

The program as blocks
Show as code
lesson.ts
basic.showString("HI")
basic.showIcon(IconNames.Happy)
basic.showIcon(IconNames.Yes)

Lily's sign is in the editor. Read it, then answer.

Drag the blocks so the tick comes first and HI scrolls last. The check ticks by itself as you build.

Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.
Lily's sign has three blocks in on start: show string HI, show icon happy face, show icon tick. What do you see?

Ten seconds after the program starts, which picture is on the screen?

Change the order: the tick first, then the happy face, then HI.

This ticks by itself when your blocks do what is asked.

ModifyChange the code on purpose and check the result.

Modify

Add a show leds block at the end and draw a picture. Which picture stays on now?

Need a hint?

show leds is in Basic. Drag it under the last block.

Another hint

Click squares in the grid to light them.

Add show number at the very top. Type your favourite number.

Need a hint?

show number is in Basic. Drag it to the top and type a number.

Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.

Add a picture you draw with show leds at the end.

This ticks by itself when your blocks do what is asked.

Add a show number block at the very start.

This ticks by itself when your blocks do what is asked.

MakeBuild something new using what you have learned. Expect a few tries; that is normal.

Make

Make a name badge. Your name scrolls across, then a picture you drew stays on the screen.

Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.
Need a hint?

show string is in Basic. Type your name into it.

Another hint

Put show leds under show string, so the picture comes last and stays on.

A name badge: your name scrolls, then a picture you draw stays on.

This ticks by itself when your blocks do what is asked.

ModifyChange the code on purpose and check the result.

Change a door sign

This door sign scrolls a word, then shows a face. Make it the sign for your classroom door: your room number, then a picture that says what happens inside.

Try it yourselfYour edits are saved in this browser.
It takes a few seconds to load. Your work in this step is kept.
For teachers

Students see that blocks in on start run once, from the top, so the order of the blocks is the order of the pictures, and the last one stays. About 35 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

No micro:bits needed: the simulator (the micro:bit picture beside the blocks) runs every program. Blocks in on start run once, when the micro:bit switches on, one after another from the top. This lesson is only about that order; the next one adds forever. Try the Make yourself: your name in show string, then a show leds picture (click the squares to light them).

Running the lesson

  1. Predict: take a vote. 'Both hearts at once' is the common wrong answer. Ask: how many blocks does the micro:bit do at a time?
  2. Run: the small heart stays. Say it plainly: blocks run top to bottom, once, and the last picture stays on.
  3. Investigate: students change the order of Lily's sign in the editor; the check ticks when it is right.
  4. Modify: show leds is the first time students draw. Ask which picture stays on after they add it.
  5. Make: the name badge. Let students show each other.

The hard part (on purpose)

Seeing that the blocks run one at a time. Ask which block ran last, instead of telling them.

When students get stuck

Stretch and support

Stretch: Make a badge that shows three things in a row, ending with the picture that should stay on all day.

Support: Give students the show string block already in on start, and ask them only to add and draw the show leds picture.

Where it leads

Next lesson: forever, so the pictures repeat instead of stopping on the last one. With real micro:bits, press Download and drag the file onto the micro:bit to run it for real.

What each step is for

Now you can
Next lesson2. Again and againPut pictures inside forever so they repeat, and use pause to set how long each one stays.