Hi,
I have python 2.7, windows 7 64bits and a arduino duemilanove 328.
I Can't communicate with arduino by pyserial, but with arduino Serial Monitor is perfect.
My program doesn't pass the line print "Connecting..." It is waiting for the arduino and nothing happens....
Python code from http://www.instructables.com/id/Arduino-and-Python/all/?lang=pt:
'''
Created on 2011-12-02
@author: Bobby Wood
'''
#Import the serial library
import serial
#Boolean variable that will represent
#whether or not the arduino is connected
connected = False
# Open the serial port that your arduino
# is connected to
ser = serial.Serial("COM3", 9600)
#loop until the arduino tell us it is ready
while not connected:
print "Connecting..."
serin = ser.read()
connected = True
print "Connected"
# Tell the arduino to blink
ser.write("1")
# Wait until the arduino tells us it
# is finished blinking
while ser.read()=="1":
ser.read()
# Close the port and end the program
ser.close()
sketch from http://www.instructables.com/id/Arduino-and-Python/all/?lang=pt:
void setup() {
// Open serial communications:
Serial.begin(9600);
pinMode(13, OUTPUT);
Serial.write('1');
}
void loop() {
// if data present, blink
if (Serial.available() > 0) {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
Serial.write('0');
}
}