Changing button action with dip switch

Hey guys!

Not super new to Arduino, been messing around with it here and there a bit for a few years. I'm currently working on a project and having been trying to find a way to take a (on) - off switch and make it 1) latching (which I've gotten solved) and 2) utilizing a DIP switch to set it to momentary. Basically the project is a switch panel to control some lights in a vehicle. I want to be able to switch the buttons between maintained and momentary without having to change the code. I've looked around and been unable to locate anything. I don't know if I'm just not looking up the right things but any help is appreciated!

Thanks!

[quote="automotivediy, post:1, topic:1063905"]
I want to be able to switch the buttons between maintained and momentary without having to change the code

Believe it or not, you actually have to define what want and then code for it and then test it. Just making vague statements is not the same thing.

1 Like

Try something like:

momentary = digitalRead(someInput)
if(momentary == HIGH){
  // do momentary switch things
}
else{
// do toggle switch things
}

The other way to do it, without any additional DIP switches is to use a short button press (say less than 500ms) for momentary, and a long button press for permanent.

The Arduino OneButton Library may be of interest

http://www.mathertel.de/Arduino/OneButtonLibrary.aspx

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.