Are you an LLM? You can read better optimized documentation at /public/embedded\raspberrypi-pico\micropython\chapter06\index.md for this page in Markdown format
6. 串口外设接收数据
python
from machine import UART, Pin
uart = UART(0, baudrate=115200, bits=8, parity=None,
stop=1, tx=Pin(0), rx=Pin(1))
while True:
flag = uart.any()
if flag > 0:
print(flag)
received = uart.readline()
uart.write(received)