//*!!Code automatically generated by 'ROBOTC' configuration wizard.              !!*//
//*!!Analog,     1,                     , ,                                      !!*//
//*!!Camera,     0,                     , ,                                      !!*//
//*!!PSCtrl,     0,                     , ,                                      !!*//
//*!!Sensor,   in1,                 gyro, sensorGyro,      ,                     !!*//
//*!!Motor,  port1,                 left, tmotorNormal,                          !!*//
//*!!Motor,  port2,                right, tmotorReversed,                        !!*//
//*!!                                                                            !!*//
//*!!Start automatically generated configuration code.                           !!*//
const tSensors gyro                 = (tSensors) in1;  //sensorGyro         //*!!!!*//
const tMotor   left                 = (tMotor) port1;  //tmotorNormal       //*!!!!*//
const tMotor   right                = (tMotor) port2;  //tmotorReversed     //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration.                !!*//

task main()
{
	int gyro_sensor = 0;
	int degree_of_turn = 900; //degrees of turn - in tenths
	int error_amount = 50;  //degree of error (10 degree range) - in tenths

	wait1Msec(250);  //Allow the GYRO to initialize and reset to current position

	while(true)
	{
		gyro_sensor = SensorValue[gyro];

		if(gyro_sensor < (degree_of_turn - error_amount))
		{
			motor[left] = 25;
			motor[right] = -25;
		}

		if(gyro_sensor > (degree_of_turn + error_amount))
		{
			motor[left] = -25;
			motor[right] = 25;
		}

		if(gyro_sensor > (degree_of_turn - error_amount)&& gyro_sensor < (degree_of_turn + error_amount) )
		{
			motor[left] = 0;
			motor[right] = 0;
		}
	}
}
