View Single Post
  #8   Spotlight this post!  
Unread 11-02-2007, 17:14
Salik Syed Salik Syed is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Alumni
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Stanford CA.
Posts: 514
Salik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud of
Send a message via AIM to Salik Syed
Re: Storing functions to variables

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
__________________
Team 701

Last edited by Salik Syed : 11-02-2007 at 17:18.