PDF

blockstblockst0.4.0

Render Scratch, Blockly, MakeCode and Open Roberta blocks for educational documents.

MakeCode block catalog#

Every block of the MakeCode editors, built from the locale files the parser reads, shown in English (language: "en"). The same blocks exist in all 36 editor languages, German being the default, see the languages of MakeCode.

micro:bit#

The makecode profile: the blocks of makecode.microbit.org.

Basic#

BlockCode
show arrow ()
show icon [ v]
clear screen
forever
end
pause (ms) ()
show string ()
show leds [#...#|.#.#.|..#..|.#.#.|#...#]
show number ()
on start
end

Input#

BlockCode
(acceleration (mg) [ v])
on button [ v] pressed
end
on [ v]
end
<button [ v] is pressed>
(light level)
(magnetic force (µT) [ v])
(rotation (°) [ v])
(running time (ms))
(running time (micros))
(sound level)
(compass heading (°))
on pin [ v] pressed
end
<pin [ v] is pressed>
on pin [ v] released
end
set accelerometer range [ v]
(temperature (°C))
<is [ v] gesture>
calibrate compass
on logo [ v]
end
<logo is pressed>
set [ v] sound threshold to ()

Music#

BlockCode
([ v] beat)
change tempo by (bpm) ()
rest for ()
ring tone (Hz) ()
set tempo to (bpm) ()
stop melody [ v]
(tempo (bpm))
music on [ v]
end
play () [ v]
set built-in speaker ()
<sound is playing>
stop all sounds
(melody [C D E F - - - -] at tempo () (bpm))
(() start frequency () end frequency () duration () start volume () end volume () effect [ v] interpolation [ v])
set volume ()

Led#

BlockCode
(brightness)
led enable ()
toggle x () y ()
plot x () y ()
plot bar graph of () up to () serial write ()
plot x () y () brightness ()
<point x () y ()>
(point x () y () brightness)
set brightness ()
stop animation
unplot x () y ()
set display mode [ v]

Radio#

BlockCode
radio send ()
on radio () received
end
radio send number ()
radio send string ()
radio send value () = ()
on radio received ()
end
on radio received () ()
end
(received packet ())
radio set frequency band ()
radio set group ()
radio set transmit power ()
radio set transmit serial number ()

Loops#

BlockCode
break
continue
repeat () times
end
while ()
end
every () ms
end
for () from 0 to ()
end
for element () of ()
end
pause until ()

Logic#

BlockCode
if () then
end
<false>
<true>
<() = ()>
<() ≥ ()>
<() > ()>
<() ≤ ()>
<() < ()>
<() ≠ ()>
<not ()>
<() and ()>
<() or ()>

Variables#

BlockCode
change [ v] by ()
set [ v] to ()

Math#

BlockCode
(pick random () to ())
<pick random true or false>
(() + ())
(() / ())
(() × ())
(() ** ())
(() - ())
(constrain () between () and ())
(convert () from [ v])
(map () from low () high () to low () high ())
(remainder of () / ())
([ v] of () and ())
(absolute of ())

Functions#

BlockCode
return ()
call function
function

Arrays#

BlockCode
(() find index of ())
() insert at () value ()
(get random value from ())
(get and remove last value from ())
remove last value from ()
() add value () to end
(() get and remove value at ())
() remove value at ()
reverse ()
(get and remove first value from ())
remove first value from ()
(() insert () at beginning)
(empty array)
(() get value at ())
() set value at () to ()
(length of array ())

Text#

BlockCode
(text from char code ())
(char code from () at ())
(compare () to ())
(char from () at ())
<() includes ()>
<() is empty>
(parse to number ())
(split () at ())
(substring of () from () of length ())
(join () ())
(length of ())
(convert () to text)

Game#

BlockCode
add life ()
change score by ()
(create sprite at x: () y: ())
delete ()
game over
<is game over>
<is paused>
<is running>
() move by ()
pause
remove life ()
(score)
set life ()
set score ()
() if on edge, bounce
() change [ v] by ()
<is () deleted>
() set [ v] to ()
<is () touching edge>
<is () touching ()>
start countdown (ms) ()
() turn [ v] by (°) ()

Images#

BlockCode
(arrow image [ v])
(icon image [ v])
(create big image [#...#|.#.#.|..#..|.#.#.|#...#])
(create image [#...#|.#.#.|..#..|.#.#.|#...#])
scroll image () with offset () and interval (ms) ()
show image () at offset () and interval (ms) ()

Pins#

BlockCode
(analog pin [ v])
analog pitch () for (ms) ()
analog set pitch pin ()
(analog read pin ())
(digital read pin ())
analog set period pin () to (µs) ()
analog write pin () to ()
digital write pin () to ()
set pin () to emit [ v] events
set pull pin () to [ v]
servo write pin () to ()
servo set pulse pin () to (µs) ()
set [ v] to touch mode [ v]
(digital pin [ v])
i2c write number at address () with value () of format [ v] repeated ()
(map () from low () from high () to low () to high ())
neopixel matrix width pin () ()
set audio pin ()
set audio pin enabled ()
(i2c read number at address () of format [ v] repeated ())
on pin [ v] pulsed [ v]
end
(pulse duration (µs))
(pulse in (µs) pin () pulsed [ v])
spi format bits () mode ()
spi frequency ()
spi set pins MOSI () MISO () SCK ()
(spi write ())

Serial#

BlockCode
serial set rx buffer size to ()
serial set tx buffer size to ()
serial set write line padding to ()
serial on data received ()
end
(serial read string)
(serial read line)
(serial read until ())
(serial read buffer ())
serial redirect to TX [ v] RX [ v] at baud rate [ v]
serial redirect to USB
serial set baud rate [ v]
serial write buffer ()
serial write line ()
serial write number ()
serial write numbers ()
serial write string ()
serial write value () = ()

Control#

BlockCode
(device name)
(device serial number)
(event timestamp)
(event value)
run in background
end
on event from () with value ()
end
raise event from source () with value ()
reset
(millis (ms))
wait for event from () with value ()
wait (µs) ()

Calliope mini#

The makecode-calliope profile adds the Calliope mini’s own blocks and recolours the shared ones; listed here are only the blocks the Calliope editor adds or words differently.

Basic#

BlockCode
show compass needle for () ms
show icon [ v] for () ms
(red () green () blue ())
show string () in an interval of () ms
set LED to ()
set LED to () () () brightness ()
show number () in an interval of () ms
turn built-in LED off

Input#

BlockCode
on button [ v] ()
end
(rotation (°) [ v])
(running time (micros))
on pin [ v] ()
end
(sound level)

Music#

BlockCode
ring tone (Hz) ()
set tempo to (bpm) ()

Led#

BlockCode
led enable ()
toggle x () y ()

Functions#

BlockCode
call tuWas

Arrays#

BlockCode
() remove value at ()
(empty array)

Text#

BlockCode
(parse to number ())

Game#

BlockCode
<is () touching edge>
<is () touching ()>

Images#

BlockCode
(create image [#...#|.#.#.|..#..|.#.#.|#...#])
show image () at offset () and interval (ms) ()

Pins#

BlockCode
(analog pin [ v])
analog set pitch pin ()
servo set pulse pin () to (µs) ()
(digital pin [ v])
I²C write number at address () with value () of format [ v] repeated ()
(I²C read number at address () of format [ v] repeated ())
(pulse in (µs) pin () pulsed [ v])

Serial#

BlockCode
serial set rx buffer size to ()
serial set tx buffer size to ()
serial redirect to USB
serial write numbers ()

Motors#

BlockCode
motor [ v] at () %