Hi! I´m new here...
I used to code in C about 20 years ago... so as a hobby I´m beginning with Arduino. I´m doing an interface to a DC motor controller.
I got a library from JChristensen (GitHub - JChristensen/JC_Button: Arduino library to debounce button switches, detect presses, releases, and long presses) to deal with button presses, long presses and debouncing.
In one of his examples (up/down counter), short presses in one button increases the counter by one unit, short presses on the other decreases by one. Long presses increase/decrease in a faster rate. And it works properly.
So I´m thinking of using his button library to my project.
My problem is.. (I searched already in google for something similar but couldn´t find an answer so far...)
I´d like to .. when a button is pressed, no other button could interfere with the action of that button. So I want the opposite of multiple presses allowed. I want only a single button allowed at a time...
Let´s say I press the button for the motor to run forward. I´d like to not be possible for pressing both at the same time and the two orders be sent for the motor to run forward and reverse at the same time.
I was trying to adapt his code (which is simple to use) but with no success so far...
So, if anyone could give me a hint on how to perform it... Having multiple buttons (more than two.. in fact maybe 5) but only allowing action on the first pressed and ignoring the others... Or giving me an idea on where to look for it, it would be nice.
If it was possible using this library I´m using it would be better and simpler yet...
Thanks for reading...
This is the example-code I´m using...
I also included the header file and cpp file from the library.
Thanks a lot for reading!
UpDown.pde (3.96 KB)
Button.h (1.79 KB)
Button.cpp (5.38 KB)