summaryrefslogtreecommitdiff
path: root/tests/circuitpython-manual/busio/uart_echo.py
blob: f55d4db9ec29b0c8ac5d71b07b8642a1db6c6e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import busio
import board
import time

i = 0

u = busio.UART(tx=board.TX, rx=board.RX)

while True:
    u.write(str(i).encode("utf-8"))
    time.sleep(0.1)
    print(i, u.in_waiting) # should be the number of digits
    time.sleep(0.1)
    print(i, u.in_waiting) # should be the number of digits
    r = u.read(64 + 10)
    print(i, u.in_waiting) # should be 0
    print(len(r), r)
    i += 1