Example: Dual D-Pad Controller Test - Simple Version 手機藍芽搖桿控制測試簡單版
#microbit #bluetooth
Description 說明:
配合手機使用 "micro:bit Blue" APP 的 "Dual D-Pad Controller"
可以控制 micro:bit顯示 按下按鈕對應的圖形
Step 步驟:
1, Install "micro:bit Blue" APP to smartphone(Android Only).
Android 手機安裝 "micro:bit Blue" APP
2. Write code by MAKECODE and update firmware to micro:bit board.
用 MAKECODE 寫程式並燒錄到板子上。
用 MAKECODE 寫程式並燒錄到板子上。
3. Pair Bluetooth with micro:bit board.
將手機和 micro:bit board 藍芽配對
將手機和 micro:bit board 藍芽配對
4. Launch "micro:bit Blue" APP
開啟 "micro:bit Blue" APP。
5. Press "FIND PAIRED BBS MICRO-BITS" button on bottom side.
按下下方 "FIND PAIRED BBS MICRO-BITS" 按鈕。
6. Select "Dual D-Pad Controller"
選擇 "Dual D-Pad Controller"。
7. Press button, and button symbol will show on micro:bit led matrix.
按下手機上控制器的按鈕,micro:bit 板子會顯示按下按鈕對應的圖形。
MAKECODE
MAKECODE
Bluetooth_DPAD_Test_Simple
control.onEvent(EventBusSource.MES_DPAD_CONTROLLER_ID, EventBusValue.MICROBIT_EVT_ANY, () => {
if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_A_DOWN) {
basic.showArrow(ArrowNames.North,0)
} else if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_B_DOWN) {
basic.showArrow(ArrowNames.South, 0)
} else if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_C_DOWN) {
basic.showArrow(ArrowNames.West, 0)
} else if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_D_DOWN) {
basic.showArrow(ArrowNames.East, 0)
} else if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_1_DOWN) {
basic.showIcon(IconNames.Triangle, 0)
} else if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_2_DOWN) {
basic.showIcon(IconNames.No, 0)
} else if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_3_DOWN) {
basic.showIcon(IconNames.Square, 0)
} else if (control.eventValue() == EventBusValue.MES_DPAD_BUTTON_4_DOWN) {
basic.showLeds(`
. # # # .
# . . . #
# . . . #
# . . . #
. # # # .
`, 0)
} else {
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
}
})
basic.showIcon(IconNames.Heart)
basic.forever(() => {
})
|
Comments
Post a Comment