I need to communicate with an Arduino. Doing serial.readline() to read what Arduino has to say works fine. Doing serial.write('something') doesn't seem to do anything.
What is interesting is that if I write the same code in the console or command-line, it works as expected...
Using Python 2.7.
Python code:
import time
import serial
# setup Arduino USB communication
try:
arduinoSerialData = serial.Serial('com3', 9600)
except: # not connected/damaged
pass
while True:
if arduinoSerialData.inWaiting() > 0:
arduinoSerialData.write('A')
arduinoSerialData.flush()
datastr = arduinoSerialData.readline()
print datastr
time.sleep(1)
.flush()