 void loop() 
 {
   delay(50);
+  if (debug_state == 0)
+  {
+    printState();
+  }
+  if (debug_state >= 0)
+  {
+    debug_state = (debug_state + 1) % 10;
+  }
+  
   int selector_pos = getSelectorGearPosition();
-  Serial.println(selector_pos);
-  return;
   if (selector_pos == -2)
   {
     sendCastleErrorMessage();


  if (state == 1)
  {
    if (selector_pos < last_selector_pos
        || selector_pos > last_selector_pos + 1)
    {


// photoresistor_history[i][j] is the state of the photoresistor i when we were
// at selector position j.  Only meaningful in state 1, and then only for
// 0 <= j <= the current selector gear position.  When we transition to state 2
// we use this to populate gear_types and gear_orientations.
// NOTE: The photoresistor is positioned down.
boolean photoresistor_history[3][7];
