task main() { SensorType[S1] = sensorSONAR; while(true) { nMotorEncoder[motorA] = 0; nMotorEncoder[motorC] = 0; motor[motorA] = 100; motor[motorC] = 100; while(nMotorEncoder[motorA] < 1200 && nMotorEncoder[motorC] < 1200 ){} if(nMotorEncoder[motorA] < nMotorEncoder[motorC]) { motor[motorC] = 0; while(nMotorEncoder[motorA] < nMotorEncoder[motorC]){} motor[motorC] = 100; } if(nMotorEncoder[motorC] < nMotorEncoder[motorA]) { motor[motorA] = 0; while(nMotorEncoder[motorC] < nMotorEncoder[motorA]){} motor[motorA] = 100; } if(SensorValue[S1] < 40) { repeat(2){ nMotorEncoder[motorA] = 0; nMotorEncoder[motorC] = 0; motor[motorA] = -100; motor[motorC] = -100; wait1Msec(500); while(nMotorEncoder[motorA] > -1200 && nMotorEncoder[motorC] > -1200 ){} if(nMotorEncoder[motorA] > nMotorEncoder[motorC]) { motor[motorC] = 0; while(nMotorEncoder[motorA] > nMotorEncoder[motorC]){} motor[motorC] = -100; } if(nMotorEncoder[motorC] > nMotorEncoder[motorA]) { motor[motorA] = 0; while(nMotorEncoder[motorC] > nMotorEncoder[motorA]){} motor[motorA] = -100; } } nMotorEncoder[motorA] = 0; nMotorEncoder[motorC] = 0; motor[motorC] = 0; motor[motorA] = 100; while(nMotorEncoder[motorA] < 8400){} } } }