#------------------------------------------------------ # serialRead.py # An example of reading data from the serial port # (Data sent from the Arduino for example.) #------------------------------------------------------ #!/usr/bin/env python import time import serial ser = serial.Serial( # Create and define a serial object "ser" port='/dev/ttyACM0', baudrate = 9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) while 1: r = ser.readline() # Read a byte from the serial port conv = r.decode("utf-8") # Convert the byte to a string conv = conv.strip('\n') # Strip off the "\n" newline character print(conv) # Print the byte-to-string conversion