Okay, awesome. Typo corrected and the following code works:
boolean debugger = false; // Verbose output
const int pinCount = 5;
const int pinList[pinCount] = {15, 16, 17, 18, 19}; // A1-A5 set as digital
void setup() {
for (int i=0; i<pinCount; i++) {
//pinMode(pinList[i], INPUT_PULLUP); // Active low, connect switch common to Ground
pinMode(pinList[i], INPUT);
digitalWrite(pinList[i], HIGH);
}
Serial.begin(9600);
delay(500);
Serial.println();
Serial.println("Serial Activated");
}
void loop() {
static int previousPosition = -1;
static boolean unused = false;
static unsigned long timer = 0;
int currentPosition = -1;
// Scan through the switch pins looking for the current position.
for (byte i=0; i<pinCount; i++) {
if (digitalRead(pinList[i]) == LOW)
currentPosition = i;
}
// Debugger
if (debugger == true) {
Serial.print("Running Position: ");
Serial.println(currentPosition);
}
// If the current position is different from the previous position:
if (currentPosition != previousPosition) {
timer = millis(); // Start a timer.
unused = true; // Set an UNUSED flag.
previousPosition = currentPosition;
}
// If the timer reaches "N" and the UNUSED flag is set:
if (millis() - timer > 1000 && unused && currentPosition != -1) { // One second
// Act on the current position. (Your code goes here)
Serial.print("Current Position: ");
Serial.println(currentPosition);
unused = false; // Clear the UNUSED flag.
}
}
Now the only thing I need is a way to send a once time signal if the switch is in the off position (currentPosition = -1). Any ideas?
Thanks again for all your help.
EDIT: Changed to CODE instead of QUOTE.