Mouldolas:
Have you an explanation about how to use .risingEdge() and .fallingEdge().
As PaulS explained, they have been deprecated, and in fact, if you look at Bounce2.h you will see that they simply return the value of .rose() and .fell(). That said, if your pushbutton is configured so that when "pressed" it provides a direct path for the pull-up resistor (external, I hope) to ground, the signal on the pin will transition from HIGH to LOW. This would mean your condition would look for .fell() to be true when the button is pressed. If it is configured to provide a direct source path for a pull-down resistor, the signal pin will transition from LOW to HIGH. This would mean your condition would look for .rose() to be true when the button is pressed.
Just for the fun of it, you could also try TButton from TDuino:
#include <TDuino.h>
#define BUTTON_COUNT 4
const byte BUTTON_PINS[BUTTON_COUNT] = { 3, 4, 5, 6 };
TButton buttons[BUTTON_COUNT];
byte buttonFlag = 0, idx;
void buttonPress(byte pin, int state)
{
//Turn on the bit that represents the button:
buttonFlag |= (1 << (pin-3));
//Serial.print(F("Button"));
//Serial.print(pin-3);
//Serial.print(F(" press"));
}
void buttonRelease(byte pin, int state)
{
//Clear the bit that represents the button:
buttonFlag &= ~(1 << (pin-3));
//Serial.print(F("Button"));
//Serial.print(pin-3);
//Serial.print(F(" release"));
}
void setup()
{
for (idx = 0; idx < BUTTON_COUNT; idx++)
{
buttons[idx].attach(BUTTON_PINS[idx]);
buttons[idx].onPress(buttonPress);
buttons[idx].onRelease(buttonRelease);
}
}
void loop()
{
//Update the buttons
for (idx = 0; idx < BUTTON_COUNT; idx++) buttons[idx].loop();
//Check the current button state
switch (buttonFlag) {
case 1:
Serial.println(F("Button1"));
break;
case 2:
Serial.println(F("Button2"));
break;
case 4:
Serial.println(F("Button3"));
break;
case 8:
Serial.println(F("Button4"));
break;
}
}
The benefits of the code above is that you can check for multiple buttons pressed, eg. if button 1 and 2 are pressed, "buttonFlag" would be 3. Or if button 3 and 4 are pressed, buttonFlag would be 12 and so on.