//******************************************************************************//
//                              For Loop                                        //
//                              RobotC on NXT                                   //
//                                                                              //
//  This program allows your taskbot to run in a square five times.             //
//                                                                              //
//******************************************************************************//
//				Focus                                           //
//                                                                              //
//  This program allows your robot to move in a sqaure by repeating a forward   //
//  and right turn movement.  It will repeat this movement 20 times so your     //
//  robot does five squares. It tracks the number of times its completed the    //
//  movement with the variable "i" in a for loop. A for loop works by tracking  //
//  the value of a variable. It does so by establishing the variable's intial   //
//  value, the condition of the variable under which the loop should continue   //
//  to run, and the quantity the variable will increase by after each iteration //
//  of the loop. In the following program "i" is initialized to equal zero,     //
//  allows the loop to repeat as long as "i" is less than 20, and is 		//
//  incremented by 1 at the end of each iteration of the loop. 	                //
//                                                                              //
//******************************************************************************//
//				Notes                                           //
//				                                                //
//  1. The wait times used may need to be customized depending on robot         //
//     configuration. Test your robot several times to find the best wait time  //
//     to get a 90 degree turn.  Once you have the proper timing, substitute it //
//     for the "wait1Msec(750)" command in the following program.               //
//  2. The robot will end facing the same direction as when it started.	        //
//                                                                              //
//******************************************************************************//
//				Motors & Sensors                                //
//                                                                              //
//  [I/O Port]          [Name]          [Type]          [Description]           //
//  Port A              none            Motor           Right Motor             //
//  Port B              none            Motor           Left Motor              //
//                                                                              //
//******************************************************************************//


task main()
{
   int i;                    //the variable "i" is declared as an integer

   for(i = 0; i< 20; i++)    //a for loop is declared that: intializes i equal to zero, continues to run under the condition i is less than 20, and increments i by one after each iteration
   {
      motor[motorA] = 75;    //motor A is run at a 75 power level
      motor[motorB] = 75;    //motor B is run at a 75 power level
      wait1Msec(4000);       //the program waits 4000 milliseconds before running further code

      motor[motorA] = 75;    //motor A is run at a 75 power level
      motor[motorB] = -75;   //motor B is run at a -75 power level
      wait1Msec(750);        //the program waits 750 milliseconds before running further code
   }
}