test_serial_loop.py 225 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import serial
import time

ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=0.1)
print(ser)
time.sleep(1.5)

def loop():
    while True:
        ser.write(b'p')
        print(ser.readline())
        time.sleep(0.01)

loop()