Thanks for the information about the centroid range...
The camera probably bounced up and down because it never realy got to the right centroid_y. I didn't understand the code, what does 3 stand for? And 120 is supposed to represent the center of the tilt, right? Now I'll repair this in the pan direction too. So lets say I call the value of the x direction as target_x (like in the demo code) then every pixel of the centroid_x range is: target_x/159?
And another question: our camera is mounted with the ON/OFF switch on top, so where is the 0 of the centroid_x and the 159 of it? Same thing about the tilt.
Oh, and about the code, I will be glad if you could give me some pseodo code to learn from.. I am a rookie as you see, and I'm getting very nevous about this camera because I can't get almost nothing from it

Thanks in advance.
:::EDIT:::
I thought about it, and isn't it easier to calculate the exact tilt location according to the centroid_y (after the conversion to rotation, 239 centroid_y pixels are 255 rotation ticks--> 255/239=1.066... rotation ticks for each pixel. So if the centroid_y is let's say at 150, then the rotation has to be:
Code:
rotation=(int)centroid_y*(255/239); // or rotation=(int)255-centroid_y*(255/239); Depends on the centroid_y direction.
SetPWM(Port_2,rotation)
Same thing about the pan servo (but not necessarily with centroid_x).
Correct me if I'm wrong please.