Python Serial Problem

Hi, I have problem with Python and my Arduino Duemilanove. On the Arduino I’m running this:

for (i = 0; i < 8; i = i + 1) {
digitalWrite(spalte[i], HIGH);
digitalWrite(spalte[in], LOW);
dly = 1050-analogRead(poti[0]);

Now I want do revice this with python on my computer (Windows 7).
But if I run this:

import serial
ser = serial.Serial('COM7', baudrate = 9600, timeout=3)
print ser.readline()

the for loop stops and start from the beginning. I only receive that where i=0. Sorry for english I’m German.


Each time a serial connection to the Arduino is made, the Arduino resets.

You need to make sure your Python script only makes one connection, not a new connection each time it wants to read data.

How can I do this? I didn’t find something like that here:

Once you open the serial connection, using serial.Serial, you need to leave it open. All the reading from the port must be done in a loop.