I'm trying to send data to Arduino UNO using Python
the Arduino code
const int controlPin = 9;
void setup(){
pinMode(controlPin, OUTPUT);
digitalWrite(controlPin, HIGH);
Serial.begin(9600);
}
void loop(){
if (Serial.available() > 0) {
int inByte = Serial.read();
switch (inByte) {
case '0':
digitalWrite(controlPin, LOW);
break;
case '1':
digitalWrite(controlPin, HIGH);
break;
}
}
}
this code is working when i open the Arduino ide and open the serial monitor and send 0 it turn off when i send 1 it turn on
im trying to do the same thing without using the ide i want to use python
i tried the following
import serial # if you have not already done so
ser = serial.Serial('/dev/ttyACM0', 9600)
ser.write('x')
anything i type in the x place it turn it on even if i typed 0 or 1 they both turn it on
any ideas ?