forked from tanchou/Verilog
16 lines
328 B
Python
16 lines
328 B
Python
![]() |
import serial
|
||
|
import time
|
||
|
|
||
|
ser = serial.Serial('COM6', 115200)
|
||
|
ser.timeout = 1
|
||
|
|
||
|
# Boucle pour lire les données du port série
|
||
|
while True:
|
||
|
if ser.in_waiting > 0:
|
||
|
data = ser.read(1)
|
||
|
|
||
|
distance = int.from_bytes(data, byteorder='little')
|
||
|
print(f'Distance reçue : {distance} cm')
|
||
|
|
||
|
ser.close()
|