Python split data from arduino serial to raspberry -
i have output serial arduino on raspberry
30.27|34.00\n 30.27|32.00\n 30.21|33.00\n
code on raspberry:
import serial ser = serial.serial('/dev/ttyacm0', 9600) while 1 : ser.readline()
i want spit this
x=30.21 y=33.00
is possible if data send in real time,
thanks..
using same code have, try:
import serial ser = serial.serial('/dev/ttyacm0', 9600) while 1 : data=ser.readline() x=data.split("|")[0] y=data.split("|")[1] print "x=",x print "y=",y
you can streamline code more wanted make step step easier reading.
Comments
Post a Comment