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

//******************************************************************************//
//                              Obstacle Detect                                 //
//                              RobotC on NXT                                   //
//                                                                              //
//  This program allows your robot to move forward until it detects an obstacle //
//  and then stops.                                                             //
//                                                                              //
//******************************************************************************//
//				Focus                                           //
//                                                                              //
//  The sonar sensor returns -1 as a value when reading any distance longer     //
//  than 255 inches.  Take this into consideration when programming your bot.   //
//                                                                              //
//******************************************************************************//
//				Notes                                           //
//				                                                //
//  1. The light Sensor is mounted on the back of the robot.                    //
//  2. Be sure to reset the rotation sensor before comparing its value.         //
//  3. The values recorded by the sonar sensor are in inches.                   //
//                                                                              //
//******************************************************************************//
//				Motors & Sensors                                //
//                                                                              //
//  [I/O Port]     [Name]          [Type]               [Description]           //
//  Port 1         sonarsensor      Sonar Sensor         port 1 sonarsensor     //
//  Port A         none             Motor                Right Motor            //
//  Port B         none             Motor                Left Motor             //
//                                                                              //
//******************************************************************************//


task main()
{
   do                                      //do instructs the computer to run the code in its braces and after 1 iteration check the condition at the while statment that follows
   {
      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(sonarSensor) > 20);   //after each iteration of the loop is conducted, the truth condition, if the sonar sensor value is greater than 20, is checked

}