Hi all,
I've an Arduino UNO (i use it with windows xp on COM5) and after a successfully serial communication with python the serial port COM5 is disappeared. Now i post the arduino and python code.
Arduino code:
int ledPin= 13;
int val=0;
char msg=' ';
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Serial.print("Program Initiated\n");
}
void loop() {
while (Serial.available()>0) {
msg = Serial.read();
}
if (msg == 'Y') {
digitalWrite(ledPin, HIGH);
Serial.print("HIGH");
msg=' ';
} else if (msg == 'N') {
digitalWrite(ledPin, LOW);
}
}
Python code:
import serial
import time
try:
arduino = serial.Serial('COM5', 9600)
time.sleep(3)
arduino.write('Y')
print arduino.readline()
print arduino.readline()
except:
print "Failed to connect on COM5"
arduino.close()
Thanks in advance