   calibration_state = -1;
   if (on)
   {
+    digitalWrite(calibration_light, HIGH);
+  }
+  else
+  {
     digitalWrite(calibration_light, LOW);
-  }
-  else
-  {
-    digitalWrite(calibration_light, HIGH);
   }
 }
 

// INPUT READING

// True if white gear is in front of photo resistor.  False if black paper.
boolean getPhotoresistor(int i) 
{
  // sees white gear
  if(analogRead(photoresistors[i]) > 850)
  {
    return true;
  }

    gear_types[i] = 1;
    if (photoresistor_history[i][1] && photoresistor_history[i][4])
    {
      gear_orientations[i] = 1;
      return true;
    }
    else if (photoresistor_history[i][2] && photoresistor_history[i][5])
    {
      gear_orientations[i] = 2;
      return true;
    }
    else
