← Reference

Talk: cheat sheet

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

show arrow

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

basic.showArrow(ArrowNames.West)
The block

change variable

Adds to a variable's value. Change by -1 counts down. Variables.

count += 1
The block

if

Runs the blocks inside only when the condition is true; does nothing when it is false. Logic.

if (condition) {
    blocks
}
The block

else if

Another question, asked only if the ones above were false. The first true one wins.

} else if (condition) {
The block

radio set group

Picks a channel (0 to 255). Only micro:bits in the same group hear each other. Radio.

radio.setGroup(1)
The block

on radio received

Runs each time a number arrives; receivedNumber holds it. Radio.

radio.onReceivedNumber(function (receivedNumber) {
    blocks
})
The block

radio send string

Sends a word to every other micro:bit in the group. Radio.

radio.sendString("hi")
The block

on radio received string

Runs each time a word arrives; receivedString holds it. Radio.

radio.onReceivedString(function (receivedString) {
    blocks
})
The block

set variable

Puts a value in a variable, throwing the old value away. Make the variable in Variables first.

let count = 0
The block

counter

Set the start value once, in on start. change adds to whatever the variable holds now.

let count = 0
input.onButtonPressed(Button.A, function () {
    count += 1
    basic.showNumber(count)
})
The block

if else

Exactly one part runs: the first when the condition is true, else the second. Click + on an if block.

if (condition) {
    blocks
} else {
    blocks
}
The block

length of list

How many items are in the list. The last place is the length − 1. Arrays.

answers.length
The block

radio send number

Sends a number to every other micro:bit in the group. Radio.

radio.sendNumber(0)
The block

which message

One on radio received gets every message; receivedNumber says which one arrived.

radio.onReceivedNumber(function (receivedNumber) {
    if (receivedNumber == 1) {
        blocks
    } else if (receivedNumber == 2) {
        blocks
    }
})
The block