← Reference

Secret codes: cheat sheet

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

show number

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

basic.showNumber(0)
The block

change variable

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

count += 1
The block

on radio received

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

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

find in text

The place where something first appears in a text, counted from 0, or -1 if it is not there. Text (find index of … in …).

alphabet.indexOf(letter)
The block

xor with a key

XOR: compares two numbers bit by bit. Doing it again with the same key brings the number back, so one key locks and unlocks. Written ^ in JavaScript and Python.

message ^ key
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 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

remainder

What is left over after dividing: 27 % 26 is 1. Wraps a count back round to the start. Math (remainder of … ÷ …).

place % 26
The block