Hello,
Can somebody tell me why, when I run my code, I'm using a camer to tell me where my head is located. and based on different intervals of x axis I want the servo motor to turn to a certain degree. But It seems like it only turns when I first run the code. After that it doesn't turn. I know it is not my code because I have printf in there and I can see that it works properly when I move my head but The servo motor doesn't move at all. Thanks in advance.
here is the servo motor part of the code:
Code:
int v=0;
int result;
double curr_pos;
const char *err;
double minAccel, maxVel;
//Declare an advanced servo handle
CPhidgetAdvancedServoHandle servo = 0;
//create the advanced servo object
CPhidgetAdvancedServo_create(&servo);
//open the device for connections
CPhidget_open((CPhidgetHandle)servo, -1);
if (head > 0.0150) //if the head is anywhere between 0.0150 to infiniti then declare that as left
{
//printf("hey I'm on left\n");
CPhidgetAdvancedServo_setEngaged(servo, v, 1);
CPhidgetAdvancedServo_setPosition (servo, v, 40.00);
}
else if((0.0150 >= head) && (head >= (-0.0400))) //if the head is anywhere between 0.0150 to -0.0400 then declare that as middle
{
//printf("hey I'm in the middle\n");
CPhidgetAdvancedServo_setEngaged(servo, v, 1);
CPhidgetAdvancedServo_setPosition (servo, v,150.00);
}
else //if the head is anywhere between -0.0400 to -infiniti then declare that as Right
{
//printf("I'm ON RIGHT\n");
CPhidgetAdvancedServo_setEngaged(servo, 0, 1);
CPhidgetAdvancedServo_setPosition (servo, 0, 210.00);
}