Microbit LED 矩阵

« 返回首页

Microbit LED 矩阵

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.

More links:<ul><li>Download a sample projects for the micro:bit LED matrix.</li><li>View the how to instructions for the micro:bit LED matrix.</li></ul>

Properties

  • BluetoothDevice – The BluetoothLE component connected to the micro:bit device (setter).

get Microbit_Led1 BluetoothDevice

set Microbit_Led1 BluetoothDevice  to

Methods

  • ReadLEDMatrixState – Read the current state of the LED matrix from the micro:bit. The LED matrix state will be reported through the LEDMatrixStateReceived event.

call Microbit_Led1 ReadLEDMatrixState

  • ReadScrollingDelay – Read the current scroll delay for the micro:bit’s LED matrix. After a successful read, the ScrollingDelayReceived event will be run.

call Microbit_Led1 ReadScrollingDelay

  • 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:

 * <code>LED_Matrix_State</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#makealist">_list_</a>) &mdash; 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.

call Microbit_Led1 WriteLEDMatrixStateLED_Matrix_State

  • 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:

+ <code>LED_Text_Value</code> (_string_) &mdash; The text to write. Strings are limited to
  a length of 20 UTF-8 octets.

call Microbit_Led1 WriteLEDTextLED_Text_Value

  • 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:

 * <code>Scrolling_Delay_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) &mdash; The delay between characters on the LED matrix, in milliseconds.

call Microbit_Led1 WriteScrollingDelayScrolling_Delay_Value

Events

  • 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:

+ <code>LED_Matrix_State</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#makealist">_list_</a>) &mdash; 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.

when Microbit_Led1 LEDMatrixStateReceived LED_Matrix_State do

  • 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:

 * <code>Scrolling_Delay_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) &mdash; The delay between characters on the LED matrix, in milliseconds.

when Microbit_Led1 ScrollingDelayReceived Scrolling_Delay_Value do

  • 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:

 * <code>LED_Matrix_State</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#makealist">_list_</a>) &mdash; The values written to the LED matrix as specified in the previous call
   to

when Microbit_Led1 WroteLEDMatrixState LED_Matrix_State do

  • WroteLEDText – 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:

 * <code>LED_Text_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/text.html#string">_text_</a>) &mdash; The text to write to the LED matrix.

when Microbit_Led1 WroteLEDText LED_Text_Value do

  • 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:

 * <code>Scrolling_Delay_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) &mdash; The delay between characters on the LED matrix, in milliseconds.

when Microbit_Led1 WroteScrollingDelay Scrolling_Delay_Value do