I am writing a Python script, that sends a character to an Arduino and the Arduino prints the received character back. But in this case, the Arduino is always giving a garbage value. Also there is no error while executing the Python script.
I have checked multiple blogs, articles and tutorials and followed the exact steps, but I got no solution.
This is my Python script:
import serial
ser = serial.Serial("/dev/ttyACM0",9600)
ser.write('8')
read=ser.readline()
print(read)
This is the Arduino code:
int temp;
void setup() {
Serial.begin(9600);
temp=5;
}
void loop() {
temp=Serial.read();
Serial.println(temp);
delay(1000);
}
Arduino always prints -1 in response.