turnRight

//Turns to a certain angle.  Negative = left
void turnRight(float angle) {

 //Figure out what direction to turn, set motors
 if(angle < 0) {
     LCD.WriteLine("I'm turning left!");

     rightMotor.SetPercent(OUTSIDE_TURN_POWER);
     leftMotor.SetPercent(INSIDE_TURN_POWER);

     Sleep(100);

     rightMotor.SetPercent(FAST_OUTSIDE);
     leftMotor.SetPercent(FAST_INSIDE);
 } else {
     LCD.WriteLine("Turning right!");
     rightMotor.SetPercent(FAST_INSIDE);
     leftMotor.SetPercent(FAST_OUTSIDE);
 }

 //Turn based on the angle desired
 Sleep(abs(angle) / TURN_ADJUST);
 rightMotor.Stop();
 leftMotor.Stop();

 return;
}

Algorithm for turnRight:

  1. If angle is less than 0, proceed to step 2, otherwise proceed to step 6.
  2. Output that the robot is turning left.
  3. Set the right motor to the outside turn power, and the left motor to the inside turn power.
  4. Pause.
  5. Set the right and left motor percents to fast. Proceed to step 8.
  6. Output that the robot is turning right.
  7. Set the right motor to fast inside, and the left motor to fast outside.
  8. Turn based off of the desired angle.
  9. Stop the left and right motors.
  10. End function.