//*!!Sensor,    S1,         touchSensor1, sensorTouch,      ,                    !!*//
//*!!Sensor,    S2,         touchSensor2, sensorTouch,      ,                    !!*//
//*!!                                                                            !!*//
//*!!Start automatically generated configuration code.                           !!*//
const tSensors touchSensor1         = (tSensors) S1;   //sensorTouch        //*!!!!*//
const tSensors touchSensor2         = (tSensors) S2;   //sensorTouch        //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration.                !!*//

//******************************************************************************//
//                              Remote Control                                  //
//                              RobotC on NXT                                   //
//                                                                              //
//  This program allows your taskbot to stay stationary while no touch sensors  //
//  are engaged. However, if both touch sensors are pressed, the robot moves    //
//  forward. If only the right touch sensor is pressed, the robot turns right,  //
//  and if only the left touch sensor is pressed then the robot turns left.     //
//                                                                              //
//******************************************************************************//
//				Focus                                           //
//                                                                              //
//  The focus of this program is to teach about having multiple while loops in a single program. //
//  With multiple while loops, you can have a range of conditions where the robot will act only when //
//  a specific part of the program is true ( such as when both touch sensor are press, as opposed to //
//  one touch sensor being pressed). This program has a single while loop that continuously checks //
// each of the the 3 possible conditions (right touch sensor, left touch sensor, both touch sensors), //
// and performs the specific parts of the code when                              //
//                                                                 //
//                                                                              //
//******************************************************************************//
//				Notes                                           //
//				                                                //
//  none                                                                        //
//                                                                              //
//******************************************************************************//
//				Motors & Sensors                                //
//                                                                              //
//  [I/O Port]     [Name]          [Type]               [Description]           //
//  Port 1         touchsensor1    Touch                Right touch sensor      //
//  port 2         touchsensor2    Touch                Left touch sensor       //
//  Port A         none            Motor                Right Motor             //
//  Port B         none            Motor                Left Motor              //
//                                                                              //
//******************************************************************************//

task main()
{
   while(true)                                                                   //an infinite while loop is delcared with true as its condition
   {
      motor[motorA] = 0;                                                         //motor A is stopped with a 0 power level
      motor[motorB] = 0;                                                         //motor B is stopped with a 0 power level

      while(SensorValue(touchSensor1) == 1 && SensorValue(touchSensor2) == 1)    //a while loop is declared with touchsensor1 and touchsensor2 having the value 1 as its true condition
      {
         motor[motorA] = 75;                                                     //motor A is run at a 75 power level
         motor[motorB] = 75;                                                     //motor B is run at a 75 power level
      }

      while(SensorValue(touchSensor1) == 1 && SensorValue(touchSensor2) == 0)    //a while loop is declared with touchsensor1 having the value 1 and touchsensor2 having the value 0 as its true condition
      {
         motor[motorA] = -75;                                                    //motor A is run at a -75 power level
         motor[motorB] = 75;                                                     //motor B is run at a 75 power level
      }

      while(SensorValue(touchSensor1) == 0 && SensorValue(touchSensor2) == 1)    //a while loop is declared with touchsensor1 having the value 0 and touchsensor2 having the value 1 as its true condition
      {
         motor[motorA] = 75;                                                     //motor A is run at a 75 power level
         motor[motorB] = -75;                                                    //motor B is run at a -75 power level
      }
   }
}