show icon
Shows a ready-made picture. Basic › show icon; click the picture to choose another.
basic.showIcon(IconNames.Heart)
micro:bit and the computer · Find each block in the MakeCode toolbox (the category is at the end of each line).
Shows a ready-made picture. Basic › show icon; click the picture to choose another.
basic.showIcon(IconNames.Heart)
Shows a number; numbers above 9 scroll. Basic › show number.
basic.showNumber(0)
Waits before the next block. 1000 ms is one second. Basic › pause.
basic.pause(500)
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)
})
Adds to a variable's value. Change by -1 counts down. Variables.
count += 1
How bright it is: 0 (dark) to 255 (bright). Input.
input.lightLevel()
How warm it is, in degrees Celsius. Input.
input.temperature()
Runs the blocks inside only when the condition is true; does nothing when it is false. Logic.
if (condition) {
blocks
}
Another question, asked only if the ones above were false. The first true one wins.
} else if (condition) {
Sends a line of text down the USB cable. Serial.
serial.writeLine("ok")
The line that arrived, as text, without its new line. Use it inside on serial data received. Serial.
serial.readLine()
Draw your own picture: click squares to light them (# is on). Basic › show leds.
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .
`)
Turns every LED off. Basic › more › clear screen.
basic.clearScreen()
Runs the blocks inside again and again. Blocks in on start run only once.
basic.forever(function () {
blocks
})
Runs the blocks inside every time the button is pressed. Choose A, B or A+B. Input.
input.onButtonPressed(Button.A, function () {
blocks
})
Puts a value in a variable, throwing the old value away. Make the variable in Variables first.
let count = 0
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)
})
Tilt: x is left (below 0) and right (above 0), y is forward and back. Input › more.
input.acceleration(Dimension.X)
Exactly one part runs: the first when the condition is true, else the second. Click + on an if block.
if (condition) {
blocks
} else {
blocks
}
Sends a line such as light:128 down the USB cable. The board graphs it; MakeCode's simulator shows it under Show data. Serial.
serial.writeValue("light", input.lightLevel())
Runs each time a whole line arrives over USB (it ends with a new line). Serial.
serial.onDataReceived(serial.delimiters(Delimiters.NewLine), function () {
blocks
})
Picks a channel (0 to 255). Only micro:bits in the same group hear each other. Radio.
radio.setGroup(1)
Runs each time a word arrives; receivedString holds it. Radio.
radio.onReceivedString(function (receivedString) {
blocks
})
Sends a word to every other micro:bit in the group. Radio.
radio.sendString("hi")
Sends a name and a number by radio, such as bin and 1. Radio.
radio.sendValue("bin", 1)
Runs each time a name and number arrive by radio. Radio.
radio.onReceivedValue(function (name, value) {
blocks
})
Scrolls a word or message across the screen. Basic › show string.
basic.showString("Hello")
The letter at a place in a text. Places start at 0, as in a list. Text (char from … at).
message.charAt(0)
Turns a servo on that pin to an angle from 0 to 180 (90 is the middle). Pins.
pins.servoWritePin(AnalogPin.P0, 90)
Shows an arrow pointing a direction. Basic › more › show arrow.
basic.showArrow(ArrowNames.West)