 #include <Bounce2.h>
 
 // Red LEDs named after the signal/switch lever/etc they're for.
-// Labeled as a8-a15, so 89-82
-int PIN_LED_SWITCH_5 = 89;  // a8
-int PIN_LED_SWITCH_1 = 88;
-int PIN_LED_SIGNAL_A2 = 87;
-int PIN_LED_SIGNAL_A1 = 86;
-int PIN_LED_SWITCHING_PERMISSION = 85;
-int PIN_LED_ROUTE_A = 84;
-int PIN_LED_ROUTE_BERENBACH = 83;
+// These are the analog ports labeled as a8-a15.
+int PIN_LED_SWITCH_5 = A8;
+int PIN_LED_SWITCH_1 = A9;
+int PIN_LED_SIGNAL_A1 = A10;
+int PIN_LED_SIGNAL_A2 = A11;
+int PIN_LED_SWITCHING_PERMISSION = A12;
+int PIN_LED_ROUTE_A = A13;
+int PIN_LED_ROUTE_BERENBACH = A14;
 // White LED
-int PIN_LED_ROUTE_A_FIXATION = 82;  // a15
+int PIN_LED_ROUTE_A_FIXATION = A15;
 
 // Levers and lock
-int PIN_LEVER_SWITCH_5 = 78;  // d22
-int PIN_LEVER_SWITCH_1 = 76;  // d24
-int PIN_LEVER_SIGNAL_A2 = 74;  // d26
-int PIN_LEVER_SIGNAL_A1 = 72;  // d28
-int PIN_LOCK_SWITCHING_PERMISSION = 58;  // d32
+int PIN_LEVER_SWITCH_5 = 22;
+int PIN_LEVER_SWITCH_1 = 24;
+int PIN_LEVER_SIGNAL_A1 = 26;
+int PIN_LEVER_SIGNAL_A2 = 28;
+int PIN_LOCK_SWITCHING_PERMISSION = 32;
 // Route levers
-int PIN_LEVER_ROUTE_A1 = 54;  // d36
-int PIN_LEVER_ROUTE_A2 = 50;  // d38
-int PIN_LEVER_ROUTE_BERENBACH1 = 52;  // d40
-int PIN_LEVER_ROUTE_BERENBACH2 = 42;  // d42
+int PIN_LEVER_ROUTE_A1 = 36;
+int PIN_LEVER_ROUTE_A2 = 38;
+int PIN_LEVER_ROUTE_BERENBACH1 = 40;
+int PIN_LEVER_ROUTE_BERENBACH2 = 42;
 // Push button for route fixing
-int PIN_BUTTON_ROUTE_A_FIXATION = 38;  // d46
+int PIN_BUTTON_ROUTE_A_FIXATION = 46;
 // Output pins (pull to 0 means go out of the ground position)
-int PIN_OUTPUT_SWITCH_5 = 6;  // pwm 2 TODO
-int PIN_OUTPUT_SWITCH_1 = 7;  // pwm 3 TODO
-int PIN_OUTPUT_SIGNAL_A1 = 1;  // pwm 4 TODO
-int PIN_OUTPUT_SIGNAL_A2 = 5;  // pwm 5 TODO
+int PIN_OUTPUT_SWITCH_5 = 2;
+int PIN_OUTPUT_SWITCH_1 = 3;
+int PIN_OUTPUT_SIGNAL_A1 = 4;
+int PIN_OUTPUT_SIGNAL_A2 = 5;
 
 // Array index numbers. These are columns in the locking table.
 int SWITCH_5 = 0;


void update_single_lever_led(int pin, int number) {
  if (position_is_ok[number] == false) {
    if ((millis() % 1000) > 500) {
      digitalWrite(pin, HIGH);
    }
    else {

  // Special case: route fixation button should take a second to activate.
  levers[ROUTE_A_FIXATION].interval(1000);

  // look up the initial lever positions and update accordingly.
  for (int number = 0; number < ARRAY_SIZE; number++) {
    levers[number].update();

    if (levers[number].read() == HIGH) {
      react_to_movement(number, PLUS);
    }
    else {
      react_to_movement(number, MINUS);
    }
  }

}


