 
 void loop() {
   // put your main code here, to run repeatedly:
-
+  
+  int mostRecentTurn = RIGHT;
+  int direction = LEFT;
+  
   if (button.isPressed())
   {
     // if button is pressed, stop and wait for another press to go again

  {
    // if leftmost sensor detects line, reverse and turn to the right
    turn(RIGHT, true);
  }
  else if (sensor_values[5] < QTR_THRESHOLD)
  {
    // if rightmost sensor detects line, reverse and turn to the left
    turn(LEFT, true);
  }
  else  // otherwise, go straight
  {


void turn(char direction, bool randomize)
{
  
  static unsigned int duration_increment = TURN_DURATION / 4;
  
  // motors.setSpeeds(0,0);
  // delay(STOP_DURATION);
      
  motors.setSpeeds(-FULL_SPEED, -FULL_SPEED);
  delay(REVERSE_DURATION);
  motors.setSpeeds(FULL_SPEED * direction, -FULL_SPEED * direction);
  delay(randomize ? TURN_DURATION + (random(8) - 2) * duration_increment : TURN_DURATION);
  motors.setSpeeds(FULL_SPEED, FULL_SPEED);
  last_turn_time = millis();
}
