I did the change and now no outputs turn on, at all. Here's the current code. I've //'d the line you specified, and put the new one in before it.
const byte noOfInput = 3; // change this into the number of input you need
const byte noOfOutput = 8; // change this into the number of output you need
const byte inputPin[noOfInput] = {11, 12, 10}; // change according to your input pin
const byte outputPin[noOfOutput] = {2, 3, 4, 5, 6, 7, 8, 9}; // change this according to your output pin
const boolean pullUp = true; //true if you use pull up resistor or internal pull up, false if you dont
const boolean outputLogic = false; // true if High mean On, false if HIGH mean off
const boolean debugMode = false; //true if you want to use Serial Monitor
const boolean outputMode = true;//Set to false if use pin 0 or 1 and debugMode true
const unsigned long debounceDelay = 100;
struct debounce
{
byte inputPin;
boolean inputState;
boolean lastInputState;
boolean currentInputState;
unsigned long lastDebounceDelay;
};
struct output
{
byte outputPin;
boolean outputState;
};
debounce switchPin[noOfInput];
output pinOutput[noOfOutput];
void setup()
{
for ( int i = 0; i < noOfInput; i++ )
{
switchPin[i].inputPin = inputPin[i];
switchPin[i].lastInputState = pullUp;
switchPin[i].lastDebounceDelay = 0;
pinMode(switchPin[i].inputPin, INPUT);
digitalWrite(switchPin[i].inputPin, switchPin[i].lastInputState);
}
for ( int i = 0; i < noOfOutput; i++)
{
pinOutput[i].outputPin = outputPin[i];
pinOutput[i].outputState = !outputLogic;
pinMode(pinOutput[i].outputPin, OUTPUT);
digitalWrite(pinOutput[i].outputPin, pinOutput[i].outputState);
}
if (debugMode) Serial.begin(115200);
}
void loop()
{
unsigned long timeNow = millis();
static byte counter = noOfOutput;
for ( int i = 0; i < noOfInput; i++ )
{
switchPin[i].currentInputState = digitalRead ( switchPin[i].inputPin );
if ( switchPin[i].currentInputState != switchPin[i].lastInputState )
{
switchPin[i].lastDebounceDelay = timeNow;
switchPin[i].lastInputState = switchPin[i].currentInputState;
}
if ( timeNow - switchPin[i].lastDebounceDelay >= debounceDelay )
{
if (switchPin[i].currentInputState != switchPin[i].inputState)
{
switchPin[i].inputState = switchPin[i].currentInputState;
if ( switchPin[0].inputState == !pullUp )
{
if (debugMode) Serial.print ("Switch 1 Press\tCounter++\t");
counter++;
if ( counter >= noOfOutput ) counter = 7;
}
if ( switchPin[1].inputState == !pullUp )
{
if (debugMode) Serial.print ("Switch 2 Press\tCounter--\t");
counter--;
if ( counter > noOfOutput ) counter = 0;
}
if ( switchPin[2].inputState == !pullUp )
{
if (debugMode) Serial.print ("Switch 3 Press\tSelect Switch Pressed\t");
if (counter < noOfOutput) pinOutput[counter].outputState = !outputLogic;
//if (counter < noOfOutput) pinOutput[counter].outputState = !pinOutput[counter].outputState;
//else if (counter == noOfOutput);
//{
//if (debugMode) Serial.print ("Turning all off\t");
// for ( int i = 0 ; i < counter ; i++)
// {
// pinOutput[i].outputState = !outputLogic;
// }
// if (debugMode) Serial.print ("All off now\t");
//}
}
if (debugMode)
{
if ( switchPin[i].inputState == !pullUp )
{
Serial.print ("Switch Press detected\t");
if (counter < noOfOutput) (pinOutput[counter].outputState) ? Serial.print ("On\t") : Serial.print ("Off\t");
Serial.println (counter);
}
}
}
}
}
if (outputMode)
{
for ( int i = 0; i < noOfOutput; i++)
{
digitalWrite(pinOutput[i].outputPin, pinOutput[i].outputState);
}
}
}
