from machine import Pin import bluetooth from ble_simple_peripheral import BLESimplePeripheral ble = bluetooth.BLE() sp = BLESimplePeripheral(ble) LED0 = Pin("LED", Pin.OUT) def on_rx(data): print("Data received: ", data) if data == b'LED0\r\n': LED0.toggle() while(1): if sp.is_connected(): sp.on_write(on_rx)