The s2m Blocks

This section describes the custom Scratch blocks added to the More Blocks section in the Scratch editor.

Display

This command block allows you to select and display an image on the micro:bit LED display.

Scroll Text

This command block allows you to enter text that will be scrolled across the LED display. The text must be in Roman characters. If not a warning will scroll across the display and appear in the command window.

Write Pixel

This command block allows you to control each individual pixel on the LED display. A pixel is chosen by specifying its x or horizontal position, y or vertical position, and its intensity or brightness.

An X value of 0 is the left most column and a value of 4 is the right most.

A Y value of 0 is the top row and a value of 4 is the bottom row.

An intensity (brightness) value of 0 is the lowest level and 9 is the highest.

If you enter a value that is out of range, it will be converted internally to valid value. Please note, that the value will not be updated in the block because Scratch does not provide a programmatic way to do so.

If you enter a negative value for any of the parameters, the value used internally will be a zero. If you enter a value greater than 4 for the x or y parameters, the value used internally will be a 4. If you enter a value greater than 9 for the intensity parameter, the value used internally will be a 9.

Clear Display

This command block will immediately turn all LED pixels off.

Digital Write

This command block allows you to set pins 0, 1, or 2 to a value of 0 or 1.

Once this block is used to set a digital output value for the selected pin, the pin mode is fixed as a digital output. As a result the Read Digital block for this pin will return a zero, until the micro:bit is reset.

If you wish to follow a digital write by an analog write for a given pin, you should first issue a digital write for the selected pin with a value of 0.

Analog Write

This command block allows you to set pins 0, 1, or 2 to a value of 0 to 1023.

Once this block is used to perform an analog write for the selected pin, the pin mode is fixed as an analog output. As a result the Read Analog block for this pin will return a zero, until the micro:bit is reset.

If you enter a value that is out of range, the value will silently be set to 256 internally. Please note, that the value will not be updated in the block because Scratch does not provide a programmatic way to do so.

Button Pressed

These binary reporter blocks report if their associated button is pressed or not. They return a value of "true" if pressed and "false" if not.

Tilt

These binary reporter blocks report if the micro:bit board is tilted in a given direction. They return a value of "true" if tilted and "false" if not.

The micro:bit is held so that the USB connector is at the top in order for the tilt directions to track correctly.

Shaken

This binary reporter block reports if the micro:bit has been shaken. It returns a value of "true" if it has been, and "false" if not.

Make sure you shake the board up and down so that it changes position vertically (relative to the ceiling and floor).

When using the shaken block, you might need to add a small delay for Scratch to "see" the shaken event.

Read Digital

This reporter block returns the current digital value for pins 0, 1, or 2. Either a value of 0 or 1 is returned.

If a Digital Write block was previously used for the pin selected, a zero will always be returned until the micro:bit is reset. Once reset, the pin may then be used as input pin.

Read Analog

This reporter block returns the current analog value for pins 0, 1, or 2. A value between 0 and 1024 is returned.

IMPORTANT NOTE: When you press the Red Stop Button in the Scratch Editor, digital and analog outputs for pins 0, 1, and 2 will be set to 0, and the LED display will be cleared.

The Brazilian-Portuguese Blocks

The Brazilian-Portuguese translation was provided by Edson Sidnei Sobreira

The Brazilian-Portuguese demo was provided by Edson Sidnei Sobreira

The Hebrew Blocks

The Hebrew translation was provided by Rami Shaked

The Japanese Blocks

The Japanese translation was provided by Junya Ishihara.

The Korean Blocks

The Korean translation was provided by 전형기.

The Spanish Blocks

The Spanish translation was provided by Sergio Gonzalez

The Spanish motion demo were provided by Edson Sidnei Sobreira.

The Traditional Chinese (TW) Blocks

The Traditional (tw) Chinese translation and motion demo were provided by HSIEH, Li-Yi (lyshie).