evert-arias / EasyButton

Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
https://easybtn.earias.me
MIT License
447 stars 62 forks source link

Multiple buttons with Callback per button #75

Open jannies opened 1 year ago

jannies commented 1 year ago

I need some help and are not sure if I am doing this correctly.

I am trying to use 2 buttons with different callbacks for the onPressed defined for each button. When any of the buttons are pressed both callback's are invoked.

See code below:

int timerPin = 0; int resetPin = 13;

EasyButton timerButton(timerPin); EasyButton resetButton(resetPin);

void onTimerPressed() { Serial.println("Timer Pressed); };

void onResetPressed() { Serial.println("Reset Pressed"); };

void setup() {

Serial.begin(9600); timerButton.begin(); timerButton.onPressed(onTimerPressed);

resetButton.begin(); resetButton.onPressed(onResetPressed); }

void loop() { timerButton.read(); resetButton.read(); }

stokni commented 1 year ago

Having the same issue with VirtualEasyButton, since this project seems to be abandoned, did you ever found a solution for it?