I was trying to program an autonomous turn using encoders and succeeded, but after the motors stopped the robot continues to turn. I tried to fix this by having after it was greater than the degrees the motors would go in reverse until the encoders were equal to the degrees specified. This is the code with the auton correcting drive code that did not work.
Thank you
void autonTurnleft (int speed, float degrees)
{
SensorValue[rightDrive1] = 0;
SensorValue[leftDrive1] = 0;
while(rightDrive() < (degrees * 3) && leftDrive() < (degrees * 3))
{
motor[backRightDrive] = -speed;
motor[frontRightDrive] = -speed;
motor[Drive3R] = -speed;
motor[backLeftDrive] = speed;
motor[frontLeftDrive] = speed;
motor[Drive3L] = speed;
}
while (rightDrive() > (degrees * 3) && leftDrive() > (degrees * 3))
{
motor[backRightDrive] = speed;
motor[frontRightDrive] = speed;
motor[Drive3R] = speed;
motor[backLeftDrive] = -speed;
motor[frontLeftDrive] = -speed;
motor[Drive3L] = -speed;
}
while (rightDrive() == (degrees * 3) && leftDrive() == (degrees * 3))
{
motor[backRightDrive] = 0;
motor[frontRightDrive] = 0;
motor[Drive3R] = 0;
motor[backLeftDrive] = 0;
motor[frontLeftDrive] = 0;
motor[Drive3L] = 0;
}
}