My team and I had only managed to make the camera track in the pan direction. We are having a serious problem tracking in the tilt direction. We are programing in EasyC pro, and since there isn't any prepared code for the camera search and tracking, we made it ourselves. Here's what our tracking function mainly does: after it finds the light (with the search function we maid witch works pretty fine), it has to find the value of the center of the light. If there is only 1 light then the value to rotate to is the centroid_x. If there are 2 lights the value to rotate to is: if the centroid_x is closer to the right, then it is about 3 pixels to the left from the upright_x, and if it's more closer to the left then it is about 3 pixels right from the bottomleft_x. After that I put the pan_move function. This function gets the value that it has to move for. The rotation is 255-value because the value and the rotation's x axle are upside down (correct me if I'm wrong). All this works pretty fine, (it moves a bit too little, but I think it's correct). Now, the big problem is the tilt direction. I set the rotation of the tilt direction to be the 255-centroid_y value (that means it has to rotate to the PWM value). But the problem is: it just goes up and down and running crazy. Our team doesn't have any idea what's the problem

Our code goes something like this:
Code:
Search_Light(); //when found it stops the movement of the servos
while(1) //infinite loop
{
Get_Target(); //Stores the x and y values to rotate to into global variables
Pan_Move(); //Moves the pan servo using PWM from the global variable
Tilt_Move(); //Moves the tilt servo using PWM from the global variable
}
The code is supposed to keep tracking the green light.
Please help us, we are sitting with this irritating problem for over 3 weeks now. We are desperate for help!

I would be very happy if someone gave us some direction to go to.