Micro:bit LED 5x5矩陣


Microbit_LED 可用於設定extension provides App Inventor users with the ability to programmatically change the BBC micro:bit開發板上的5x5 LED矩陣狀態,可透過程式設定各種圖案或文字。字元之間的The scrolling speed of the display may also be customized.

參考資料:


屬性

  • BluetoothDevice – 連接至micro:bit 裝置之BluetoothLE元件。

get Microbit_Led1 BluetoothDevice

set Microbit_Led1 BluetoothDevice  to


方法

  • ReadLEDMatrixState – 讀取micro:bit矩陣當下的狀態,讀取成功之後會自動呼叫LEDMatrixStateReceived事件。

call Microbit_Led1 ReadLEDMatrixState

  • ReadScrollingDelay – 讀取micro:bit的LED矩陣當下的捲動延遲時間值。成功讀取之後就會自動呼叫ScrollingDelayReceived事件。

call Microbit_Led1 ReadScrollingDelay

  • WriteLEDMatrixState – 寫入micro:bit的LED矩陣狀態。LED_Matrix_State是由五個數字所組成的清單(0~31),代表LED矩陣上各列上的哪個LED要亮起。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。執行完本方法之後就會呼叫WroteLEDMatrixState事件。事件變數是由五個數字所組成的清單,每個元素代表矩陣的一列。每個數字的範圍皆為0-31,左到右的LED數值分別為16、8、4、2、1。

    參數:

    • LED_Matrix_State (清單) — 5個數字所組成的清單,分別代表LED矩陣的一列,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 – 將文字顯示於micro:bit的LED矩陣。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。如果要發送長度大於20 octets的字串會使得訊息被切斷。

    參數:

    • LED_Text_Value (字串) — 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, theWriteScrollingDelay will be called.

    Parameters:

    • Scrolling_Delay_Value (number) — 矩陣上每個字元之間的延遲時間,單位為毫秒。

call Microbit_Led1 WriteScrollingDelayScrolling_Delay_Value


事件

  • LEDMatrixStateReceived – 成功讀取LED矩陣狀態之後就會自動呼叫本事件。。LED_Matrix_State事件變數是由五個數字所組成的清單,每個元素代表矩陣的一列。每個數字的範圍皆為0-31,左到右的LED數值分別為16、8、4、2、1。在此為二進位的概念,也就是說數字3 = 2+1,代表00011,最右邊的兩顆燈亮起;14 = 8+4+2,代表01110,中間三顆燈亮起。

    參數:

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

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 method.

    參數:

    • Scrolling_Delay_Value (number) — The delay between characters on the LED matrix, in milliseconds.

when Microbit_Led1 ScrollingDelayReceived Scrolling_Delay_Value do

  • WroteLEDMatrixState – 成功藉由WriteLEDMatrixState方法寫入LED矩陣之後,就會自動呼叫本事件。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.

    參數:

    • LED_Matrix_State (清單) — The values written to the LED matrix as specified in the previous call to

when Microbit_Led1 WroteLEDMatrixState LED_Matrix_State do

  • WroteLEDText – 成功藉由WriteLEDText方法將文字顯示於LED矩陣之後,就會自動呼叫本事件。所要寫入的文字是由LED_Text_Value參數所指定。

    參數:

    • LED_Text_Value (text) — 要顯示於LED矩陣上的文字。

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 theWriteScrollingDelay method.

    參數:

    • Scrolling_Delay_Value (number) — 矩陣上每個字元之間的延遲時間,單位為毫秒。

when Microbit_Led1 WroteScrollingDelay Scrolling_Delay_Value do