//MUX0 if (buttonState0 != lastButtonState0) { // if the state has changed, increment the counter if (buttonState0 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX0 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX0 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState0 = buttonState0;

//MUX1 if (buttonState1 != lastButtonState1) { // if the state has changed, increment the counter if (buttonState1 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX1 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX1 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState1 = buttonState1;

//MUX2 if (buttonState2 != lastButtonState2) { // if the state has changed, increment the counter if (buttonState2 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX2 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX2 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState2 = buttonState2;

//MUX3 if (buttonState3 != lastButtonState3) { // if the state has changed, increment the counter if (buttonState3 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX3 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX3 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState3 = buttonState3;

} delay (10); //delay 10 for read between values

}

here is the scimaticshttp://i48.tinypic.com/qsthms.jpg

thank you in advance its driving me crazy i dont know were or how to implement the debounce

//MUX0 if (buttonState0 != lastButtonState0) { // if the state has changed, increment the counter if (buttonState0 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX0 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX0 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState0 = buttonState0;

//MUX1 if (buttonState1 != lastButtonState1) { // if the state has changed, increment the counter if (buttonState1 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX1 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX1 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState1 = buttonState1;

//MUX2 if (buttonState2 != lastButtonState2) { // if the state has changed, increment the counter if (buttonState2 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX2 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX2 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState2 = buttonState2;

//MUX3 if (buttonState3 != lastButtonState3) { // if the state has changed, increment the counter if (buttonState3 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX3 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX3 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState3 = buttonState3;

int buttonState[4]; // the current reading from the input pinint lastButtonState[] = {LOW,LOW,LOW,LOW}; // the previous reading from the input pinlong lastDebounceTime[] = {0,0,0,0}; // the last time the output pin was toggled

long debounceDelay = 50; // the debounce time; increase if the output flickers

//MUX0 if (buttonState0 != lastButtonState0) { // if the state has changed, increment the counter if (buttonState0 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX0 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX0 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState0 = buttonState0;

//MUX1 if (buttonState1 != lastButtonState1) { // if the state has changed, increment the counter if (buttonState1 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX1 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX1 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState1 = buttonState1;

//MUX2 if (buttonState2 != lastButtonState2) { // if the state has changed, increment the counter if (buttonState2 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX2 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX2 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState2 = buttonState2;

//MUX3 if (buttonState3 != lastButtonState3) { // if the state has changed, increment the counter if (buttonState3 == HIGH) { // if the current state is HIGH then the button // wend from off to on: Serial.print("MUX3 button "); Serial.print(count); Serial.println(" pressed"); } else { // if the current state is LOW then the button // wend from on to off: Serial.print("MUX3 button "); Serial.print(count); Serial.println(" released"); } } // save the current state as the last state, //for next time through the loop lastButtonState3 = buttonState3;

I made an error in my code, it was this "for(counter = 0; counter <= MAX_PINS; i++)" But change it to "for(counter = 0; counter <= MAX_PINS; counter++)"It works with multiple buttons, I just tried it and it works perfectly.