     // apart, set a dynamic threshold halfway between.
     photoresistor_history[j] = (
       photoresistor_totals[i][j] / photoresistor_counts[i][j]
-      < photoresistor_thresholds[i]);
+      > photoresistor_thresholds[i]);
+    Serial.print(photoresistor_history[j]);
 
     positions_white += photoresistor_history[j];
   }

  {
    // print out position of the pot
    Serial.print("pot: ");
    Serial.println(getSelectorGearPosition());
    // print out the three photoresistors.
    Serial.print("photoresistors:");
    for (int i=0; i<3; i++)
    {
      Serial.print(" ");
      Serial.print(getRawPhotoresistor(i));
      Serial.print(" (");
      Serial.print(analogRead(photoresistors[i]));
      Serial.print(")");
    }
    Serial.println("");
    

  if (state == 1)
  {
    blinkCalibration();
    if (selector_pos >= 0 && (selector_pos < last_selector_pos
        || selector_pos > last_selector_pos + 1))
    {
      // They have gone backwards or too fast.
      state = 0;
      resetLights();
    }
    else if (selector_pos >= 0)
    {
      // Fill in new photoresistor states.
      for (int i=0; i<3; i++)
