from machine import Pin, UART
import time
uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))
boton_azul = Pin(14, Pin.IN, Pin.PULL_DOWN)
boton_rojo = Pin(15, Pin.IN, Pin.PULL_DOWN)
ultimo_estado_azul = 0
ultimo_estado_rojo = 0
while True:
estado_azul = boton_azul.value()
estado_rojo = boton_rojo.value()
if estado_azul == 1 and ultimo_estado_azul == 0:
cad_bin = "A".encode("ASCII")
uart.write(cad_bin)
time.sleep_ms(200)
if estado_rojo == 1 and ultimo_estado_rojo == 0:
cad_bin = "R".encode("ASCII")
uart.write(cad_bin)
time.sleep_ms(200)
ultimo_estado_azul = estado_azul
ultimo_estado_rojo = estado_rojo