#pragma config(I2C_Usage, I2C1, i2cSensors) #pragma config(Sensor, I2C_1, BLenc, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Sensor, I2C_2, FRenc, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Sensor, I2C_3, BRenc, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Sensor, I2C_4, FLenc, sensorQuadEncoderOnI2CPort, , AutoAssign) #pragma config(Motor, port2, BL, tmotorVex393_MC29, openLoop, encoderPort, I2C_1) #pragma config(Motor, port3, FR, tmotorVex393_MC29, openLoop, reversed, encoderPort, I2C_2) #pragma config(Motor, port4, BR, tmotorVex393_MC29, openLoop, reversed, encoderPort, I2C_3) #pragma config(Motor, port5, FL, tmotorVex393_MC29, openLoop, encoderPort, I2C_4) #pragma config(Motor, port6, LLB, tmotorVex393_MC29, openLoop) #pragma config(Motor, port7, CLMP, tmotorVex393_MC29, openLoop, reversed) #pragma config(Motor, port8, RFL, tmotorVex393_MC29, openLoop, reversed) #pragma config(Motor, port9, RBL, tmotorVex393_MC29, openLoop, reversed) task autonomous() { nMotorEncoder[BL] = 0;//clear nMotorEncoder[FR] = 0;//clear nMotorEncoder[BR] = 0;//clear nMotorEncoder[FL] = 0;//clear //encoder set zero wait1Msec(100); while (nMotorEncoder[BL] >-84 && nMotorEncoder[FR] >-84 && nMotorEncoder[BR] >-84 && nMotorEncoder[FL] >-84)//while the encoders are all less than -84 counts { { if(nMotorEncoder[BL] < nMotorEncoder[FR] && nMotorEncoder[BR] && nMotorEncoder[FL])//if the back left motor counts are greater than the rest { motor(BL) = -127/2;//motor will move slower motor(FR) = -127;//motor will move motor(BR) = -127;//motor will move motor(FL) = -127;//motor will move } else if (nMotorEncoder[FR] < nMotorEncoder[BL] && nMotorEncoder[BR] && nMotorEncoder[FL])//if the front right motor counts are greater than the rest { motor(BL) = -127;//motor will move motor(FR) = -127/2;//motor will move slower motor(BR) = -127;//motor will move motor(FL) = -127;//motor will move } else if (nMotorEncoder[BR] < nMotorEncoder[BL] && nMotorEncoder[FR] && nMotorEncoder[FL])//if the back right motor counts are greater than the rest { motor(BL) = -127;//motor will move motor(FR) = -127;//motor will move motor(BR) = -127/2;//motor will move slower motor(FL) = -127;//motor will move } else if (nMotorEncoder[FL] < nMotorEncoder[BL] && nMotorEncoder[FR] && nMotorEncoder[BR])//if the front left motor counts are greater than the rest { motor(BL) = -127;//motor will move motor(FR) = -127;//motor will move motor(BR) = -127;//motor will move motor(FL) = -127/2;//motor will move slower } else if (nMotorEncoder[FL] == nMotorEncoder[BL] == nMotorEncoder[FR] == nMotorEncoder[BR])//if all counts are equal { motor(BL) = -127;//motor will move motor(FR) = -127;//motor will move motor(BR) = -127;//motor will move motor(FL) = -127;//motor will move } }//move backwards } } task main () { }