summaryrefslogtreecommitdiff
path: root/tests/circuitpython-manual/busio/uart_echo.py
blob: d429c7781cd54a23456faba39b5829bca1520273 (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