Arduino and Processing Communication

Hi everyone

I’m currently building an Arduino controlled head, I’ve learnt how to control it using just Arduino and now I’m trying to bring some extra fun in.

I’ve started working towards using a Kinect as it’s eyes. So I want the eyes to follow me, not mimic me - which is what most tutorials seem to focus on.

I’ve worked out what I think is a way to do it, but in practise I’m getting some issues.

I’m using enableHands() in the SimpleOpenNI(0.27) patch for Processing and have found the xy coordinates of my hand. I have then mapped them to a figure between 0-255 because that is what I have learnt the limits of a serial port are.

point(mapHandVec.x, mapHandVec.y);

xValue = int(255*mapHandVec.x/width);
yValue = int(255*mapHandVec.y/height);

I’ve then sent this information through the port to my Arduino

myPort.write(‘S’);
myPort.write(xValue);
myPort.write(yValue);

My Arduino code looks like this -

https://llihennia.files.wordpress.com/2 … 420&h=1200

So you can see after recieving the data from the Serial Port I have mapped it to be a value between 0-179 which is the limits of the Servo.

However, I cannot get my Serial Monitor to respond properly to me, it throws up something like this -

https://llihennia.files.wordpress.com/2 … 420&h=1492

So the numbers are not matching and therefore the Servos go a little bit crazy and definitely are not following my hand movements.

My assumption is that there is too much information being pulled through the Serial Port, but I may be completely wrong.

(The Processing sketch runs fine, my Kinect window appears and I can track my hand)

If someone could shine some light I would be eternally grateful!

Thanks in advance

Annie :?