         right();
         past = 'r'; //set past movement to right
         count++; //increment abandon search count
-      } else if (rightDist <= 600 || perRightDist <= 600) {
-        //if there is an object beyond 600mm of the left sensors (i.e. there is something closer in the right sensors), move right
+      } else if (rightDist <= far || perRightDist <= far) {
+        //if there is an object beyond farmm of the left sensors (i.e. there is something closer in the right sensors), move right
         right();
         past = 'r'; //set past movement to right
         count = 0; //reset abandon search count because the robot has found an object
-      } else if (leftDist <= 600 || perLeftDist <= 600) {
-        //if there is an object beyond 600mm of the right sensors (i.e. there is something closer in the left sensors), move left
+      } else if (leftDist <= far || perLeftDist <= far) {
+        //if there is an object beyond farmm of the right sensors (i.e. there is something closer in the left sensors), move left
         left();
         past = 'l'; //set past movement to left
         count = 0; //reset abandon search count because the robot has found an object

char past; //what direction the robot was moving previously
int count; //counter for how long before the rebot gives up searching in one direction
int threshold; //threshold for line sensors
int cur; // current time
int initTime; // time after initialization
short iter;
int maxS;
int minS;

void setup() {
  Serial.begin(9600);

  leftDist = sensor2.getDist();
  perRightDist = sideright.getDist();
  perLeftDist = sideleft.getDist();
  prevLine = millis();
  prevIR = prevLine;
  setSpeed(128, 20);
}

void loop() {
  curLine = millis();
  curIR = curLine;
  
  //print out values from sensors and motors to the console
  Serial.print(past);
  Serial.print(", ");
  Serial.print(rightDist);
  Serial.print(", ");
  Serial.print(leftDist);
  Serial.print(", ");
  Serial.print(perRightDist);
  Serial.print(", ");
  Serial.print(perLeftDist);
  Serial.print(", ");
  Serial.print(analogRead(backleft));
  Serial.print(", ");
  Serial.print(analogRead(backright));
  Serial.print(", ");
  Serial.print(analogRead(frontleft));
  Serial.print(", ");
  Serial.println(analogRead(frontright));
  Serial.print(", ");
  Serial.println(curLine - prevLine);
    
  if ((curLine - prevLine) >= 5) {
    prevLine = curLine;
    if (analogRead(backleft) < threshold) { //first read from line sensors before doing anything else
      //if line detected by back-left line sensor, turn left a bit
      move(1, 40, 1); //motor 1, full speed, left
