View Single Post
  #3   Spotlight this post!  
Unread 11-25-2015, 12:41 PM
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 490
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Off Season Programming Question: Switch Statements

Once I add the while loop will the method I am using for switching between case statements work?

Code:
void Autonomous(void)
	{
		myRobot.SetSafetyEnabled(false);

         
         while(IsAutonomous && IsEnabled){
		switch (step){
			case 1:
				pid.Enable();
				pid.SetTolerance(.1);
				pid.SetOutputRange(-.5, .5);
				pid.SetSetpoint(497);

				if(pid.OnTarget()){
					step++;
				}

				break;

			case 2:
				pid.Enable();
				pid.SetTolerance(.1);
				pid.SetOutputRange(-.25, .25);
				pid.SetSetpoint(800);

				if(pid.OnTarget()){
					step++;
				}

				break;


			default:
				break;
		}
            }
	}
Reply With Quote