int sisend = 0; void setup() { Serial.begin(9600); pinMode(13, OUTPUT); pinMode(7, INPUT); } void loop() { if (Serial.available() > 0) { sisend = Serial.read(); if(sisend==97){ digitalWrite(13, HIGH); } if(sisend==98){ digitalWrite(13, LOW); } if(sisend==99){ Serial.println(digitalRead(7)); } } } /* >>> import serial >>> ser=serial.Serial("COM4") >>> ser.write(b'c') 1 >>> ser.readline().decode("ascii").strip() '1' >>> ser.write(b'c') 1 >>> ser.readline().decode("ascii").strip() '0' >>> ser.write(b'c') 1 >>> ser.inWaiting() 3 >>> ser.readline().decode("ascii").strip() '0' >>> ser.inWaiting() 0 >>> ser.close() */