from machine import UART,Pin
import time
import _thread
# 设置波特率和串口号
uart0 = UART(0, baudrate=9600,tx=Pin(0),rx=Pin(1))
LED=machine.Pin(25,machine.Pin.OUT)
#线程1定时发送其他数据
def write():
i=0
while True:
i=i+1
msg="w=%d"%(i)
print(msg)
uart0.write(msg)
LED.toggle()
time.sleep(1)
_thread.start_new_thread(write,())
while True:
if uart0.any() == 0:
continue
r = uart0.readline()
print(r)
uart0.write(r)
06-01
2710
05-07
4938
08-03
1768