 void sendCastleErrorMessage()
 {
   // TODO(benkraft): May or may not need to wait a tick to be sure here.
+  // TODO(benkraft): May want to log debugging info here.
   Serial.println(21);
 }
 
-// Return the type and orientation of the gear in the nth position, or -1 for
-// both if no gear is lodged.
-// Type is 0, 1, 2, in order of the correct solution.
-// Orientation is 0 in the correct solution, 1 if we are one step clockwise
-// from it, and so on.
-void getOrientationAndTypeForGear(int gear_num, int* type, int* orientation)
-{
-  *type = -1;
-  *orientation = -1;
-  for (int i=0; i<12; i++) {
-    if (getGearConnection(gear_num, i, (i + 3) % 12))
-    {
-      *type = 0;
-      *orientation = (4 + i) % 12;  // actually equivalent mod 3
-      return;
-    }
-    else if (getGearConnection(gear_num, i, (i + 6) % 12))
-    {
-      *type = 1;
-      *orientation = i % 6;  // actually equivalent mod 3
-      return;
-    }
-    else if (getGearConnection(gear_num, i, (i + 2) % 12))
-    {
-      *type = 2;
-      *orientation = (4 + i) % 12;  // actually equivalent mod 4
-      return;
-    }
-  }
-}
-
-boolean getGearConnection(int gear_num, int slot1, int slot2)
-{
-  return getConnection(gear_connections[gear_num][slot1],
-                       gear_connections[gear_num][slot2]);
-}
-
-// all pins are tied to ground with a 12kOhm resistor
-// we drive one of the pins high (changing its impedance mode) and read the other pin
-// if high, we're connected, if low, not connected
-// pins on separate gears will never be connected
-// returns true if the pins are connected
-// side effects: briefly turns pin1 high, but returns it to input mode after
-boolean getConnection(int pin1, int pin2) 
-{
-  pinMode(pin1, OUTPUT);
-  digitalWrite(pin1, HIGH);
-  
-  boolean rtrn = false;
-  if (digitalRead(pin2)) {
-    rtrn = true;
-  }
-  delay(2000);
-  
-  digitalWrite(pin1, LOW);  
-  pinMode(pin1, INPUT);
-  
-  return rtrn;
+void printState()
+{
+  // TODO(benkraft): internal state too?
+  // print out position of the pot
+  Serial.print(getSelectorGearPosition());
+  // print out the three photoresistors.
+  for (int i=0; i<3; i++)
+  {
+    Serial.print(" ");
+    Serial.print(getPhotoresistor(i));
+  }
+  Serial.println("");
+}
+
+
+// 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;
+  }
+  // sees black paper
+  return false;
 }
 
 // based on the pot value, we know which of the 7 positions the selector gear is in

  {1, 5}, {1, 9}, {5, 9},
  {2, 6}, {2, 10}, {6, 10}};

// this runs once when the program starts
void setup() 
{

  
  // else: val is below pot_locs[0] or greater than pot_locs[7]
  // puzzle is borken
  return -1;
}
