Free Trial

Chapter 2

How to Display Things on Micro:Bit screen

In the previous exercise, you have learnt how to write and download the codes to the micro bit via the Microsoft PXT platform.

Now we are going to explore some of the basic function code blocks of the Microsoft PXT such as the display functions.

Throught this exercise, we are also going to understand one of the the fundemental principle of programming - Sequential principle

• Code Block Palette
• How to display a number
• How to display a image
• How to scroll a word
• Sequential pinciple
• Forever loop
• Pause and delay

Duration: 30 mins

micro bit chapter 2

What You Need

1 x BBC micro:bit
1 x AAA battery pack
1 x USB to MicroUSB cable
1 x Laptop/PC
1 x Micro:Bit Auto Uploader (Software)

micro bit
usb cable
battery pack

Code Block Palette

For easy reference and usage, the code block are organized into different catagories depending on the function they serve.

Each catagory is assigned to a color and listed in the code palette.

Clicking on the palette will bring up the code blocks housed in the catagory.

In this chapter, we are going to explore the basics family which consist of:

• show number
• show leds
• show string
• clear screen
• forever
• pause

microsoft PXT code palette

Displaying Number

To display a number on the LED screen of the micro bit, we can use the show number code block.

show number 0

The code block will display a number on the LED screen.

It will slide left if it has more than one digit.

You can see the results with the virtual micro bit. Codes written are automatically updated to it.

To display a different number, you can type and change the number inside the code block. Let's try changing it to 8 and download the code to your micro bit.

show number 8
show number 0
show number 8

Image & Picture

Beside displaying a number, we can also draw an image on the LED screen in anyway we like. Use the show leds code block and select the leds that you want them to light up.

show leds

The show leds block lets you control individual leds on the board.

Try drawing a big X on the code block and download it to the microbit.

show leds X
microbit showing leds

Scroll a Word

In programming, a string is used to represent text, letters, numbers and punctuation.

The show string code block can be used to scroll words and sentences across the LED screen.

show string

Try changing the words in the code block to your name and download the code to your micro bit and see.

show string


A computer is a machine that follows instructions (codes). Codes can be arranged in sequence for computer to execute it in defined order.

Codes written are read from Top to Bottom in programming language.



Codes are executed one by one in sequence (one thing at a time), never together.

In this example, the "show number" will be done first, followed by "show string" and finally the "show leds".

Forever Loop

How do we execute the same codes multiple time?

One way is to put multiple codes in sequenece. However, this will make your code script long and lengthy. (imagine you got to repeat 50 times or infinity times).

A better way is to use a Loop. A loop will repeat the code nested in it.

forever loop

A forever loop will keep repeating the nested code infinity times.


forever loop example

Time Delay

Giving the computer speed in this era, codes are executed at very fast speed.

Time delay can be introduced to the codes to make the user experience better.

forever loop

The pause code block can stop the program for the number of milliseconds. You can use this function to slow your program down.


pause example

The clear screen code block is used to turn off all the LED lights on the LED screen.

Well Done!

Learn how to code your project using buttons as inputs in the next chapter.