← Reference

Talk: cheat sheet

Robotics challenges · Find each block in the MakeCode toolbox (the category is at the end of each line).

play melody

Plays notes on the micro:bit: a letter for each note, - for a rest, at a speed in beats per minute. Until done waits for the tune to end; in background moves on at once. Music › play melody.

music.play(music.stringPlayable("C D E F G A B C5", 120), music.PlaybackMode.UntilDone)
The block

show number

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

basic.showNumber(0)
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

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

play tone

Plays one note on the micro:bit for a number of beats. In background, so the program carries on. Music › play tone.

music.play(music.tonePlayable(262, music.beat(BeatFraction.Whole)), music.PlaybackMode.InBackground)
The block

show string

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

basic.showString("Hello")
The block

pause

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

basic.pause(500)
The block

change variable

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

count += 1
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

true or false

A variable can hold true or false, to remember what is happening now. Logic.

waiting = true
The block