I want to send serial data ('a'
) to my arduino using python.
The receiving code on the arduino is the following:
char inChar = (char)Serial.read();
if(inChar=='a'){
//do stuff
}
When sending the charachter 'a' from the arduino serial terminal, it works.
However, when sending from python 2.7 (code see below), the rx led flashes but to stuff
is not executed (i.e. inChar=='a'
is false).
I tried everything but I can't solve this problem.
Pyhton code:
import serial
ser = serial.Serial('/dev/ttyUSB0',9600)
ser.write('a')
EDIT: ser.write(b'a')
doesn't work neither
ser.flush()
at the end orser.close()
reference from link to make sure the data is sent – warl0ck