 };
 
 // Globals
-const int FLASH_DELAY = 10;     // How many ticks to pass through before turning on/off LED
-                                // when in ACC state. Increasing this number makes the blink
-                                // slower. Since the main loop sleeps 30ms a value of 10 here
-                                // waits 300ms in ON then 300ms in OFF.
+const int FLASH_DELAY = 10;    // How many ticks to pass through before turning on/off LED
+                               // when in ACC state. Increasing this number makes the blink
+                               // slower. Since the main loop sleeps 30ms a value of 10 here
+                               // waits 300ms in ON then 300ms in OFF.
+                                                          
+const int HOLD_MS = 1000;      // Milliseconds to hold button to transition from ACC->START 
+                               // or from RUN->ACC                             
                  
-unsigned int tick = 0;          // Count cycles for LED flash mode (unsigned so when it rolls
-                                // over it restarts at 0
-int brightness = 0;             // How bright the LED is (usable range 0-255)
-int fadeAmount = 5;             // How many points to fade the LED by when in OFF state      
-
-int previousButtonState = HIGH; // Stores the previous button state so we can see if it changes
-sysState runState = OFF;        // Stores current system run state
+unsigned int tick = 0;         // Count cycles for LED flash mode (unsigned so when it rolls
+                               // over it restarts at 0
+int brightness = 0;            // How bright the LED is (usable range 0-255)
+int fadeAmount = 5;            // How many points to fade the LED by when in OFF state  
+
+int previousButtonState = LOW; // Stores the previous button state so we can see if it changes
+long pressTime;                // When the button was pressed 
+
+sysState runState = OFF;       // Stores current system run state
 
 /**
  * Setup runs once when system is reset, Setup pins and default states

            break;
          case OFF: // Off -> Acc
            runState = ACC;
            digitalWrite(RELAY_ACC, LOW);
            digitalWrite(RELAY_IGN, HIGH);
            digitalWrite(RELAY_START, HIGH);
            break;
          case ACC: // Acc -> Start
            runState = START;
            digitalWrite(RELAY_ACC, HIGH);
            digitalWrite(RELAY_IGN, LOW);
            digitalWrite(RELAY_START, LOW);
            break;
          case START: // Start -> Run
            // This state should never really be hit since we bump from START->RUN when
            // we release the push button switch during the START sequence
            runState = RUN;
            digitalWrite(RELAY_ACC, HIGH);
            digitalWrite(RELAY_IGN, LOW);
            digitalWrite(RELAY_START, HIGH);
            break;
          case RUN: // Run -> Off
            runState = OFF;
            digitalWrite(RELAY_ACC, HIGH);
            digitalWrite(RELAY_IGN, HIGH);
            digitalWrite(RELAY_START, HIGH);
            break;
        }
        
        Serial.println("System State:");
        Serial.println(runState);
      } else {
        // Special case for START
        // When we release the push button in the START state we want to immediately
        // transition to RUN
        if (runState == START) {
          // Turn off starter solenoid and move to RUN
          digitalWrite(RELAY_START, HIGH);
          runState = RUN;
        }
      }
    }
    // Store button state for next cycle
    previousButtonState = buttonState;
  } else {
    runState = DISABLED;
    digitalWrite(RELAY_ACC, HIGH);
    digitalWrite(RELAY_IGN, HIGH);
    digitalWrite(RELAY_START, HIGH);
  }
  // Set brightness for next cycle
  setLedBrigtness();
  // Wait for 30 milliseconds
  delay(30);
}

/**

 * * START the RELAY_START and RELAY_IGN are energized/ON
 * * RUN the RELAY_IGN is energized/ON
 * 
 * If the KILL_SWITCH circuit is grounded then the whole system is DISABLED and the relays are
 * immediately deenergized and the button no longer can transition states. If the circuit is
 * opened the system transitons to the OFF state.
 * 
 * When the kill switch is closed the system is enabeled and has the basic flow of:
 * OFF -> ACC -> (OFF | START) -> RUN -> (OFF | ACC)
 * * To transition from OFF -> ACC depress and release the push button
 * * To transition from ACC -> OFF depress and release the push button under HOLD_MS (1sec)
 * * To transition from ACC -> (START) -> RUN depress and hold the push button in until 
 * * vehicle is started and then release the button. The initial depress starts a timer that
 * * once held for over HOLD_MS (1sec) puts the system in START mode and then the release
 * * of the button once the vehicle is started transitions to RUN mode. Note, if the 
 * * SAFE_SWITCH is grounded the this transition will not be conducted.
 * * To transition from RUN -> OFF depress and release the push button.
 * * To transition from RUN -> ACC depress and hold the push button longer than HOLD_MS 
 * * (1sec) then release.
 * 
 * Because the timing to kick over the motor can be different for various vehicles and you
 * do not want not run the starter too long which may grind the flywheel/flexplate teeth the
 * I decided to keep the amount of time the starter is engaged to the actual press, just like
 * turning a key. The system could be modified to do it based on time in the future.
 * 
 * @author Chris Fitzpatrick
 * @version 1.0 02/11/2017
 * @license MIT License
 */

// Pin Definitions

// LEDs
const int LED_BUTTON   = 9;  // Push button LED
const int LED_ON_BOARD = 13; // Onboard will not fade because there is no PWM attached,
                             // but can at least give indication of state when not  
                             // using 12v input for testing/debug
// Switches
const int PUSH_BUTTON = 2;   // Momentary push button
const int KILL_SWITCH = 3;   // This is any input to enable/disable the system, could be NFC 
                             // trigger/physical switch, if grounded system is disabled.
const int SAFE_SWITCH = 4;   // Brake/Clutch/Neutral safety switch, if grounded cannot start.
                             
// Relays
const int RELAY_ACC   = 5;
const int RELAY_IGN   = 6;
const int RELAY_START = 7;
const int RELAY_4     = 8;   // Not Used

// System state
enum sysState {
