I'm building a Arduino based remote box for controlling a Speaker selector volume monitor unit thru rs485
I have a Arduino code for the switches which are designed for Normal(open) and Pushed(close)
But I found some nice EAO switches but unfortunately they are Normal(close) and pushed(open).
When the switch is read, it will result in HIGH or LOW. One each for the condition of the switch being pressed or not.
Which is pressed and which is not pressed depend on both how the switch is wired, the normal state of the switch and then how the software makes decisions based on that result.
As well, and never too soon to know, if you wanted a momentary pushbutton to act like a press-on press-off switch, this too woukd be a matter of software.
And… if you were stuck with a press- on press-off button, software coukd make that appear as if it were a momentary switch.
Yes. Although looking at just the code you posted, the spk1_button_status doesn't need inverting.
Basically you can just apply the fix immediately you read the button.
Also, it is advised to read the button once, and use what you read (stored in a variable) in the rest of the loop. This further localizes the change needed to compensate for a button type or how you wired it.
Just this day I repeated some advice I got some years ago - never mind how long precisely - so read here for a handy trick: