How about this:
in python:
for i in range(1, 500):
x = serialport.read(size=1)
y = serialport.read(size=1)
z = serialport.read(size=1)
and in arduino:
void loop () {
Serial.print(analogRead(0)/4, BYTE);
Serial.print(analogRead(1)/4, BYTE);
Serial.print(analogRead(2)/4, BYTE);
delay (40);
}
However, there are some problems with this "protocol":
1) You send positions all the time, even if the potentiometer doesn't move. You will see this in speed that you can move the cube at the slow baud rate.
2) You have no way of syncronizing the communication. You will see this when you start the arduino, then start the blender script. Sometimes your #1 potentiometer will be X, sometimes Y, sometimes Z, because you aren't syncing the xyz.
You could modify your python and arduino code like this to account for #2: (I don't know python - but in C this is what I would do...)
for i in range(1, 500):
// wait for the start data marker (two 0's in sequence)
int icount=0;
do
{
c = serialport.read(size=1)
if(c==0)
icount++;
else
icount=0;
} while(icount<2)
x = serialport.read(size=1)
y = serialport.read(size=1)
z = serialport.read(size=1)
// reset of your code here...
and the arduino code for the above python scriptlet:
void loop () {
serial.print(0,BYTE);
serial.print(0,BYTE);
serial.print(0,BYTE);
Serial.print(analogRead(0)/4, BYTE);
delay (40);
}