以下の手順でP0に接続したGrove 4digit displayにBluetooth経由で値を表示する事ができます。
1. Raspberry Piにbluepyをインストール
bluepyをRaspberry Piにインストールするの手順で、bluepyをインストールします
2. micro:bitでbluetoothサービスを使用するプログラム作成
以下のような感じでUART bluetoothサービスを最初に追加します
※Grove拡張機能ではgithub.com/seeed-studio/pxt-groveを指定します。
また、ペアリングをしなくても利用できるようにします
3. Grove 4 digit displayに値を表示するプログラム
uart4digitdisplay.py
from bluepy import btle
per = btle.Peripheral("XX:XX:XX:XX:XX:XX", btle.ADDR_TYPE_RANDOM)
# UART Service
svcUART = per.getServiceByUUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E")
# TX Characteristics
chTX = svcUART.getCharacteristics("6E400002-B5A3-F393-E0A9-E50E24DCCA9E")[0]
# RX Characteristics
chRX = svcUART.getCharacteristics("6E400003-B5A3-F393-E0A9-E50E24DCCA9E")[0]
chRX.write("1234\n".encode("utf-8"))
4. Bluetoothで4桁表示ディスプレイに値を表示するプログラムの実行
python3 uart4digitdisplay.py
〇GroveシールドとGrove 4 digit displayを接続したmicrobit
関連情報
・Groveデバイスまとめ・Bluetooth Developer Studio Level 3 Profile Report



0 件のコメント:
コメントを投稿