 
   wheel_left.attach(MOTOR_OUT_L);
   wheel_right.attach(MOTOR_OUT_R);
+
+  pinMode(DEBUGGER_ATTACHED_PIN, INPUT_PULLUP);
+  manual_control = digitalRead(DEBUGGER_ATTACHED_PIN) == LOW;
 
   // pinMode(STOP_BUTTON, INPUT_PULLUP);
   // pinMode(DOWN_BUTTON, INPUT_PULLUP);


int speed = 0;
int dir = 0;

Metro debug_out = Metro(100);


  dist_l = analogRead(DIST_IN_L);
  dist_r = analogRead(DIST_IN_R);
  dir = 0;

  if (Serial.available()) 
  {
    /* read the most recent byte */
    byteRead = Serial.read();
    if (byteRead == 'a')
    {
      manual_control = !manual_control;
    }
  }

  if (manual_control)
  {
    left_mapped = left_zero;
    right_mapped = right_zero;
  }
  else
  {
    more_space = dist_l - dist_r;

    if (more_space > 0)
      dir += map(more_space, 0, 300, 5, 120);
    else
      dir += map(abs(more_space), 0, 300, 5, -120);

    if (dir >= 0)
      dir_sign = 1;
    else
      dir_sign = -1;

    dir = map(dist_f, 50, 400, dir, dir_sign * 180);

    left_mapped = map_speed(
      map(dir, -90, 0, 0, 100), 
      left_rw_max, left_zero, left_fwd_max);
    right_mapped = map_speed(
      map(dir, 0, 90, 100, 0),
      right_rw_max, right_zero, right_fwd_max);
  }

  if (debug_out.check() == 1)
  {
    if (manual_control)
    {
      Serial.write("MANUAL ");
    }
    else
    {
      Serial.write("BOT ");
    }
    p(F("L %03d, F %03d, R %03d, dir %03d, left_mapped %03d, right_mapped %03d"),
      dist_l, dist_f, dist_r, dir, left_mapped, right_mapped);
  }

  wheel_right.write(right_mapped);
