JohnPunnett
Active member
Hi All, I am trying to read some data over serial port using a python prog on my laptop. I am basically reading an analog port on Teensy & sending the data to Serial monitor every 1/2 sec using:
int value = analogRead(analogInPin);
Serial.println(value);
This all works fine & I can see the analog data in Serial Monitor tool on IDE.
I have written a very basic Python 3 prog to read & display this data as follows:
import serial
import time
ser = serial.Serial('COM5', 9600)
while 1:
try:
line = ser.readline()
print(line)
time.sleep(1)
Whenever I run the Python 3 prog I get error:
SyntaxError: unexpected EOF while parsing
I have spent ages googling this but cant get pass this first hurdle. Eventually I want to plot data on my laptop but need to be able to read it first..
I'm sure I am missing something simple but banging my head at the moment.
Thks, John
int value = analogRead(analogInPin);
Serial.println(value);
This all works fine & I can see the analog data in Serial Monitor tool on IDE.
I have written a very basic Python 3 prog to read & display this data as follows:
import serial
import time
ser = serial.Serial('COM5', 9600)
while 1:
try:
line = ser.readline()
print(line)
time.sleep(1)
Whenever I run the Python 3 prog I get error:
SyntaxError: unexpected EOF while parsing
I have spent ages googling this but cant get pass this first hurdle. Eventually I want to plot data on my laptop but need to be able to read it first..
I'm sure I am missing something simple but banging my head at the moment.
Thks, John