//*!!Code automatically generated by 'ROBOTC' configuration wizard. !!*// //*!!Analog, 0, , , !!*// //*!!Camera, 0, , , !!*// //*!!PSCtrl, 0, , , !!*// //*!!Sensor, in1, START_BUTTON, sensorTouch, , !!*// //*!!Sensor, in2, ENCODER, sensorRotation, , !!*// //*!!Motor, port1, LEFT_MOTOR, tmotorReversed, !!*// //*!!Motor, port2, RIGHT_MOTOR, tmotorNormal, !!*// //*!! !!*// //*!!Start automatically generated configuration code. !!*// const tSensors START_BUTTON = (tSensors) in1; //sensorTouch //*!!!!*// const tSensors ENCODER = (tSensors) in2; //sensorRotation //*!!!!*// const tMotor LEFT_MOTOR = (tMotor) port1; //tmotorReversed //*!!!!*// const tMotor RIGHT_MOTOR = (tMotor) port2; //tmotorNormal //*!!!!*// //*!!CLICK to edit 'wizard' created sensor & motor configuration. !!*// task main() { int maxTicks = 2200; int time = 0; int currentTicks = 0; int motorSpeedL = 127; int motorSpeedR = 83; while(SensorValue[START_BUTTON] == 0) { } wait1Msec(500); ClearTimer(T1); SensorValue[ENCODER] = 0; motor[LEFT_MOTOR] = motorSpeedL; motor[RIGHT_MOTOR] = motorSpeedR; while((currentTicks = SensorValue[Encoder]) < maxTicks) { time = time1[T1]; if(currentTicks + 200 > maxTicks) { motorSpeedL /= 2; motorSpeedR /= 2; } } motor[LEFT_MOTOR] = 0; motor[RIGHT_MOTOR] = 0; }