from servo import Servo
from machine import Pin
import time
from BLE import BLEUART
import utime
def interrupt(pin):
motor.move(0)
time.sleep(0.3)
motor.move(90)
pir=Pin(2, Pin.IN)
pir.irq(trigger=Pin.IRQ_RISING, handler=interrupt)
name = "XDDD"
print(name, "Conectado al Bluetooth")
ble = bluetooth.BLE()
uart = BLEUART(ble,name)
def on_rx():
rx_recibe = uart.read().decode().strip()
uart.write("EspBot dice: " + str(rx_recibe) + "\n")
print(rx_recibe)
if rx_recibe == "s":
led.value(1)
if rx_recibe == "n":
led.value(0)
uart.irq(handler = on_rx)