The Microbit_LED
extension provides App Inventor users with the ability to programmatically change the BBC micro:bit’s 5x5 LED matrix, either by coding custom patterns or writing text strings. The scrolling speed of the display may also be customized.
ReadLEDMatrixState
– Read the current state of the LED matrix from the micro:bit. The LED matrix state will be
reported through the LEDMatrixStateReceived
event.ReadScrollingDelay
– Read the current scroll delay for the micro:bit’s LED matrix. After a successful read, the
ScrollingDelayReceived
event will be run.WriteLEDMatrixState
– Write the state of the micro:bit’s LED matrix. LED_Matrix_State
should be a list
of 5 numbers from 0-31 to indicate which LEDs should be turned on in each of the 5 rows of the
LED matrix. From left to right, the values of the LEDs are 16, 8, 4, 2, 1. For example, if you
want to turn on the LEDs in one row such that power states were 10011, you would send the value
(16 + 2 + 1) or 19 for the row. After the write operation completes, the
WroteLEDMatrixState
event will be run.
Parameters:
LED_Matrix_State
(list) — A list of 5 numbers, one for each row of the LED matrix, where each
value is the integer value of the bit array for the nth row of the LED matrix.WriteLEDText
– Write text to the micro:bit’s LED matrix. The rate at which each character appears on the
micro:bit’s display depends on the last scroll value written by
WriteScrollDelay
. Due to the allowable length of
Bluetooth low energy packets, the strings sent are restricted to 20 or more UTF-8 octets.
Attempts to write strings longer than 20 octets will result in truncated messages.
Parameters:
LED_Text_Value
(string) — The text to write. Strings are limited to
a length of 20 UTF-8 octets.WriteScrollingDelay
– Set the delay between characters displayed on the micro:bit’s LED matrix, in milliseconds.
After writing the value, the
WriteScrollingDelay
will be called.
Parameters:
Scrolling_Delay_Value
(number) — The delay between characters on the LED matrix, in milliseconds.LEDMatrixStateReceived
– The LEDMatrixStateReceived
event is run when the state of the micro:bit’s LED
matrix is read from the device. The LED_Matrix_State
is a list of 5 values, one
for each row of the matrix. Each value is an number from 0-31. From left to right, the LEDs
are valued 16, 8, 4, 2, 1.
Parameters:
LED_Matrix_State
(list) — A list of 5 values, one for each row, with
each value being between 0-31 to indicate which LEDs in that row are on.ScrollingDelayReceived
– The Scrolling_Delay_Value
event will be run after requesting the scrolling delay
for the micro:bit’s LED matrix through the
<a href=”#ReadScrollingDelay>ReadScrollingDelay
</a> method.
Parameters:
Scrolling_Delay_Value
(number) — The delay between characters on the LED matrix, in milliseconds.WroteLEDMatrixState
– The WriteLEDMatrixState
event will be run after the micro:bit’s LED matrix is
written due to a call to WriteLEDMatrixState
.
The LED_Matrix_State will be the same as in the call to WriteLEDMatrixState
to
differentiate the response to potentially many calls to write the LED matrix.
Parameters:
LED_Matrix_State
(list) — The values written to the LED matrix as specified in the previous call
toWroteLEDText
– The WroteLEDText
event will be run after text is written to the micro:bit’s LED
matrix through a call to WriteLEDText
. The value of
the written text will be given by the LED_Text_Value
parameter.
Parameters:
LED_Text_Value
(text) — The text to write to the LED matrix.WroteScrollingDelay
– The WroteScrollingDelay
event will be run after the micro:bit’s scrolling delay
is successfully read after a call to the
WriteScrollingDelay
method.
Parameters:
Scrolling_Delay_Value
(number) — The delay between characters on the LED matrix, in milliseconds.