 
 void setup()
 {
-  // Setup input pins
   for (int player = 0; player < PLAYERS; player++)
   {
+    // Setup select pin
+    pinMode(SELECT[player], OUTPUT);
+    digitalWrite(SELECT[player], HIGH);
+
+    // Setup input pins
     for (int pin = 0; pin < INPUT_PINS_PER_PLAYER; pin++)
     {
       pinMode(inputPins[player][pin], INPUT);
       digitalWrite(inputPins[player][pin], HIGH);
     }
-  }
-  
-  // Setup select pins
-  for (int player = 0; player < PLAYERS; player++)
-  {
-    pinMode(SELECT[player], OUTPUT);
-    digitalWrite(SELECT[player], HIGH);
   }
   
   Serial.begin(9600);

/*
 * Sega Controller Reader
 * Author: Jon Thysell <thysell@gmail.com>
 * Version: 1.2
 * Date: 6/27/2017
 *
 * Reads buttons presses from Sega Genesis 3/6 button controllers
 * and reports their state via the Serial connection. Handles hot
 * swapping of controllers and auto-switches between 3 and 6 button
 * polling patterns.
 *
 */
 
const int PLAYERS = 2;
const int INPUT_PINS_PER_PLAYER = 6;

};
 
// Controller states
int currentState[] = { 0, 0 };
int lastState[] = { -1, -1 };
 
// Default to three-button mode until six-button connects
boolean sixButtonMode[] = { false, false };
