Noobie question about connection between Python and Arduino!

Hello there!
I'm pretty new to python and arduino, and it's my first time trying to make them work together. I use python's open cv toolbox to gather some coordonates of a ball on a plate. Based on them i have to use some servo-motors to change those coordonates by tilting the plate.

My question is: How do i send the info over to arduino, about the two integers x and y, and separate them in the arduino code to use them on different servos?

I alrdy done one coordonate to one servo, for both x y axes, separately, but i fail to do it for both at the same time.

Thanks and sorry for my english! :smiley:

This Simple Python - Arduino demo may help.

Or you could use Power_Broker's SerialTransfer.h

...R

perhaps old school, but straight forward

results

123,456
x 123, y 456
788,    300
x 788, y 300

from

void setup() {
    Serial.begin(9600);
}

void
myXy (
    char *s)
{
    int x,y; 
    sscanf (s, "%d,%d", &x, &y);

    char t [40];
    sprintf (t, "x %d, y %d", x, y);
    Serial.println (t);
}

void loop()
{
    static char s [40];
    static int  i = 0;

    if (Serial.available ())  {
        s [i] = Serial.read();
        if ('\n' == s [i++])  {
            s [i-1] = 0;
            Serial.println (s);
            i = 0;

            myXy (s);
        }
    }
}