 
 // TODO(benkraft): change return signature to however you want to represent gears
 // returns which gear type is inserted + the orientation of the gear
-void getOrientationAndTypeForGear(int gear_num)
+// Return the type and orientation of the gear in the nth position, or -1 for
+// both if no gear is lodged.
+void getOrientationAndTypeForGear(int gear_num, int* type, int* orientation)
 {
   // so the basic idea here is that each gear is attached in 12 places
   // a pair of them will be connected

  // TODO(bhomberg): open solenoid??
}

// gears have been taken out / selector gear goes back to beginning, reset everything
void reset()
{

  Serial.print("  ");
  Serial.println(getConnection(gear_connections[0][0], gear_connections[0][1]));
  
  // First, get the state of the world.
  int gear_types[3];
  int gear_orientations[3];
  boolean should_reset = false;
  for (int i=0; i<3; i++)
  {
    getOrientationAndTypeForGear(i, &gear_types[i], &gear_orientations[i]);
    showLodged(i, should_reset);
    if (gear_types[i] = -1)
    {
      should_reset = true;
    }
  }

  // If not all gears are lodged, reset -- which may be a no-op -- and exit.
  if (should_reset)
  {
    reset();
    return;
  }

  // TODO(benkraft): figure out whether there is a connection on current
  // selector position

  // check if we won
  int winning = true;
  for (int i=0; i<7; i++)
  {
    if (!correct_positions[i])
    {
      winning = false;
    }
  }

  if (winning)
  {
    sendCastleSuccessMessage();
    // TODO(benkraft): Should we reset here or something?
  }
}

void sendCastleSuccessMessage() 
