← Reference

Show and react: cheat sheet

micro:bit Foundations · Find each block in the MakeCode toolbox (the category is at the end of each line).

show icon

Shows a ready-made picture. Basic › show icon; click the picture to choose another.

basic.showIcon(IconNames.Heart)
The block

show string

Scrolls a word or message across the screen. Basic › show string.

basic.showString("Hello")
The block

show arrow

Shows an arrow pointing a direction. Basic › more › show arrow.

basic.showArrow(ArrowNames.West)
The block

pause

Waits before the next block. 1000 ms is one second. Basic › pause.

basic.pause(500)
The block

animation

Pictures inside forever repeat, in order. Each pause holds the picture before it.

basic.forever(function () {
    basic.showIcon(IconNames.Heart)
    basic.pause(500)
    basic.showIcon(IconNames.SmallHeart)
    basic.pause(500)
})
The block

show leds

Draw your own picture: click squares to light them (# is on). Basic › show leds.

basic.showLeds(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .
    `)
The block

show number

Shows a number; numbers above 9 scroll. Basic › show number.

basic.showNumber(0)
The block

clear screen

Turns every LED off. Basic › more › clear screen.

basic.clearScreen()
The block

forever

Runs the blocks inside again and again. Blocks in on start run only once.

basic.forever(function () {
    blocks
})
The block

on button pressed

Runs the blocks inside every time the button is pressed. Choose A, B or A+B. Input.

input.onButtonPressed(Button.A, function () {
    blocks
})
The block

on shake

Runs the blocks inside every time the micro:bit is shaken (or tilted, if you choose another gesture). Input.

input.onGesture(Gesture.Shake, function () {
    blocks
})
The block