You can't use the same function for both because a single function can only store one 'previous state'. You can use a single function if you pass both the pin number and a REFERENCE to the previous state.
boolean ButtonPressed(byte input_pin, boolean &lastState) {
boolean buttonState = digitalRead(input_pin);
boolean pressed = false;
if (buttonState != lastState) { // State has changed
lastState = buttonState; // Record the new state
if (buttonState)
pressed = true;
}
return pressed;
}
// Example calls:
const byte UP_STOP_SW = 0;
int buttonPushCounter_up = 0; // counter for the number of button presses
boolean lastButtonState_up = 0; // previous state of the button
const byte DW_STOP_SW = 29;
int buttonPushCounter_dw = 0; // counter for the number of button presses
boolean lastButtonState_dw = 0; // previous state of the button
if (ButtonPressed(UP_STOP_SW, lastButtonState_up))
buttonPushCounter_up++; // Count presses
if (ButtonPressed(DW_STOP_SW, lastButtonState_dw))
buttonPushCounter_dw++; // Count presses