 // gear position.  When we transition to state 2 we use this to populate
 // gear_types and gear_orientations.
 // NOTE: The photoresistor is positioned down.
-int photoresistor_totals[3][7];
-int photoresistor_counts[3][7];
+long int photoresistor_totals[3][7];
+long int photoresistor_counts[3][7];
 
 // The state of the ith gear, if we know it.  This is not its current position,
 // but rather the position corresponding to selector gear 0!  Only meaningful

    {
      blinkWinningLights();
    }
  }

  last_selector_pos = selector_pos;

  if (state == 0)
  {
    setCalibration(false);
    if (selector_pos < 0)
    {
      return;
    }
    else if (selector_pos == 0 && buttonPressed())
    {
      // We have started calibrating!
      state = 1;
