# UART channel 0, GPIO 0 (Tx, pyhsical pin 1) and GPIO 1 (Rx, pin 2)
from machine import Pin
import machine
import time
led=Pin(13, Pin.OUT)
# Configurando el UART a 8N1
# 8 bist de datos, no partidad, 1 bit de parada
uart = machine.UART(0, 9600)
print(uart)
uart.write("Prueba del Puerto Serial Raspberry Pi Pico\n")
time.sleep(0.2)
while True:
if uart.any():
print("Dato RX")
rawIn = uart.readline()
try:
dataIn = rawIn.decode('utf-8').strip()
print("Entrada RX :", dataIn)
except:
pass
led.toggle()
print("Estado LED = ", led.value())
x = led.value()
uart.write(f"Estado LED {x}\n")
time.sleep(0.5)