micropython 範例十七
用手機 BLE Scanner app 透過 BLE 來控制內建 LED 燈
android 下需先安裝 BLE Scanner app
# 範例十七:
# 用手機 BLE Scanner app 透過 BLE 來控制內建 LED 燈
# 手機需安裝 BLE Scanner app
# 需要的 module : ble_uart,tools,const
# FB : https://www.facebook.com/mason.chen.1420
import ubluetooth as bt
from ble_uart import BLEUART
from tools import BLETools
from const import BLEConst
from machine import Pin
def rx_callback(data):
print((data))
if (data) == (b'on'):
Pin(12, Pin.OUT).value(1)
if (data) == (b'off'):
Pin(12, Pin.OUT).value(0)
ble = bt.BLE(); uart = BLEUART(ble, rx_callback,name="esp32_ble")