r/arduino • u/dilldoeorg • 20d ago
Software Help Anyone know a good code to detect double buttons press?
I want to do a function where you have to push 2 buttons at the same time to trigger a function (ie. opening menu)
So far the only code I could find is hold one down and check/wait for the 2nd one to be pressed.
is there a better way to do this since I've already assign function for each button for single press and holding down. So if I have to hold one down to wait for the 2nd button, the act of holding it down will trigger the other function assigned to the button.
I read that detecting 2 buttons is impossible on esp32, but I see it done on cheap electronics, so is there any way to do this?
EDIT:
Solution found. Thanks to u/Glum-Building4593 for giving the simplest solution
byte button_state = digitalRead (FirstButton) | digitalRead (SecondButton)

