2025年10月18日土曜日

積み残し Micro:bit :: BLE & Maqueen

https://tomosoft.jp/design/?p=47415 

WebBluetoothを用いたmicro:bit ver2.21との通信 windowsで成功

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

----------------どうもラズパイとウブンツではBLEは鬼門?ーーーーーーーーーーーーーーー

 https://zenn.dev/kotaproj/articles/pi_microbit_kiso :: microbit and raspi  うごかず!

https://tomosoft.jp/design/?p=47415 ubuntuでだめ  ウィンドウズならOKだった不思議

--------------------MICRO:BITはMAQUEENが便利だがScratch同様カスタム化は困難------------

 https://learn.switch-education.com/microbit-tutorial/ micro:bit 基礎

https://sanuki-tech.net/micro-bit/appendix-sample-program/compass/

磁力計基礎 最初にキャリブレ必要だった BLEつかえるが無線機能には及ばん

https://supernove.hatenadiary.jp/entry/2021/03/10/014516 LEDサービスの例

BLEサービス
V2
加速度計サービス
MicroBitBLEService OK nrf etc
ボタンサービス
MicroBitBLEService ?
入出力端子サービス
MicroBitBLEService, MicroBitComponent ?
LEDサービス
MicroBitBLEService OK mit app
温度計サービス
MicroBitBLEService    OK nrf etc
磁力計サービス
MicroBitBLEService ?
UARTサービス
MicroBitBLEService OK nrf (MAQUEEN用に受信がつかえそう)


https://monomonotech.jp/kurage/webbluetooth/microbit_ble_block_uart_rx.html ::
 ble-uart受信サービスの例題 もし。。なら、部分一部改変でうごいた


https://monomonotech.jp/kurage/webbluetooth/microbit_ble_block.html は送信例
nordic connect(app)でtempが見れた ledサービスは、aを書き込むとaがでた!

----------------------------maqueen is great-------------------------------------------------------------

https://sanuki-tech.net/micro-bit/kit/remote-control-micro-maqueen/ 拡張機能からmaqueenをえらぶ ブロックのほうがわかりやすいがデバックがしにくい!ブリントデバッグで変数チェックが有効! Obniz,MITappInventorでは、もっと困難だろう

maqueen with ble


bluetooth.onBluetoothConnected(function () {
basic.showIcon(IconNames.Yes)
})
bluetooth.onBluetoothDisconnected(function () {
basic.showIcon(IconNames.No)
})
bluetooth.onUartDataReceived(serial.delimiters(Delimiters.NewLine), function () {
data = bluetooth.uartReadUntil(serial.delimiters(Delimiters.NewLine))
if (data.includes("f")) {
maqueen.motorRun(maqueen.Motors.All, maqueen.Dir.CW, 90)
basic.pause(500)
maqueen.motorStop(maqueen.Motors.All)
} else if (data.includes("b")) {
maqueen.motorRun(maqueen.Motors.All, maqueen.Dir.CCW, 90)
basic.pause(500)
maqueen.motorStop(maqueen.Motors.All)
} else if (data.includes("t")) {
maqueen.motorRun(maqueen.Motors.M1, maqueen.Dir.CW, 90)
maqueen.motorRun(maqueen.Motors.M2, maqueen.Dir.CCW, 90)
basic.pause(500)
maqueen.motorStop(maqueen.Motors.All)
}
})
let data = ""
basic.showString("Hello!")
bluetooth.startUartService()
basic.forever(function () {
})


0 件のコメント:

コメントを投稿