← Reference

Sense: cheat sheet

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

robot motor tank

Sets the left and right wheel speeds, from −100 to 100. Same speeds go straight, opposite speeds spin, different speeds curve. The robot keeps going until another motor block.

robot.motorTank(50, 50)
The block

robot set color

Sets the robot's lights to a colour. Click the colour to choose another; black turns them off.

robot.setColor(0xff0000)
The block

forever

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

basic.forever(function () {
    blocks
})
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

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

robot obstacle distance

How far away the nearest thing in front is, in centimetres (up to 40; 40 means nothing in range). Read it again in forever to follow it.

robot.obstacleDistance()
The block

robot detect line

True when that line sensor (left or right) is over the dark line. Steer towards the side that still sees it.

robot.detectLine(RobotLineDetector.Left)
The block

show icon

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

basic.showIcon(IconNames.Heart)
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

else if

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

} else if (condition) {
The block

pick random

A random whole number from the first to the second, both included. Math.

randint(0, 10)
The block