View Single Post
  #3   Spotlight this post!  
Unread 26-01-2008, 14:55
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: Using While Statements

If you use a while loop, the program essentially "pauses" there and stops communicating with everything. You should use a global state variable. So, you would have something like:

int gyro_state = 0;

void check_gyro()
{
if (gyro_state == 0 && temp_gyro_angle >= 900)
gyro_state = 1;
if (gyro_state == 0) //temp_gyro_angle has always been less than 900
//insert code here
if (gyro_state == 1) //temp_gyro_angle has been more than 900
//insert code here
}