Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ser = serial.Serial('/dev/ttyUSB0', baudrate=115200)
- print("azzero il pwm e aspetto 5 sec")
- ser.write(str.encode("0"))
- time.sleep(3)
- print("avvio")
- while True:
- for numero in range(50):
- # leggi cosa torna indietro e stampalo
- # questa funzione invia il dato
- ser.write(str.encode(str(numero + 20)))
- #delay di 4 secondi
- time.sleep(4)
- #pulisco i buffer
- ser.flushInput()
- ser.flushOutput()
- #menorizzo in una stringa leggo quello che arduino mi fa tornare indietro
- ser_bytes = ser.readline()
- #stampo la stringa
- print("dati letto: %s"%ser_bytes)
- #pulisco i buffer
- ser.flushInput()
- ser.flushOutput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement