I need to communicate with an Arduino. DoingWhen I use serial.readline() to read what Arduino has to say it works fine. Doing But when I useserial.write('something') doesn't seem to do anything.
What is interestingInteresting thing 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 serial
import time
arduinoSerialData = serial.Serial('com6', 9600)
time.sleep(1)
while True:
arduinoSerialData.write('AAA')
arduinoSerialData.flush()
sleep(0.5)
Arduino code:
void loop() {
if (Serial.readString().startsWith("AAA")) {
digitalWrite(7, LOW);
} else {
digitalWrite(7, HIGH);
}
delay(500);
Again, Python code runs fine from the console, so no idea why this happens.