when you call the function simply put TILT_SERVO in the parameter
i.e :
Code:
double range
void someFunction ( blah blah)
{
range = DistanceCalc(TILT_SERVO);
}
or:
printf("The Distance is: %lf inches\n", DistanceCalc(TILT_SERVO));
if you want to assign your variable the value TILT_SERVO
just declare it (outside of the main loop, towards the beginning of the file under the #defines)
like this: double tiltS;
then insidde your main loop put this code:
tiltS = TILT_SERVO;
this is probably redundant and un-necessary since you already have TILT_SERVO holding the value of the camera tilt
also you may want to be wary of this line
Code:
tiltD = ((tiltS - 124) * 65) / 124;
you should change it to this:
Code:
tiltD = ((tiltS - 124) * 65) / 124.0;
Just to clarify that you do not in any case want to do integer division