Replace menu with rockerswitches

Hi

I have a menu for setting some values that are used by the sketch. It works with a rotary encoder and is pretty basic. I bought a joystick module and found that using the joystick to set values is much easier (and faster). I use it to ++/-- values, and because of the 2-axis I can set 2 values at once, removing 2 options from the menu. I have reduced the memory to only 3 items and I think that it's a waste of space to have that much code for just 3 values. It would reduce the overal code by almost 50%.

So I figured I could use 2 rocker switches to replace the whole menu. A combination of those 2 switches would trigger a different 'menu' and I can use the joystick to modify 2 values per menu.

The only thing I am not certain about is the rocker switches. Are the pitfalls when using rockers switches? I'm not seeing them much in projects (other than on/off).

Thanks!

snewpers:
...
The only thing I am not certain about is the rocker switches. Are the pitfalls when using rockers switches? I'm not seeing them much in projects (other than on/off).
...

I am maybe not understanding your problem. A rocker switch is just a switch it is eirther on or off. There is no problem with them though, as with any mechanical switch, you may need to debounce them.

Thanks Ardly,

There's no problem but it seems every time I have a 'good' idea it works out differently than I expected. I need to debounce a spst switch, too?

Thanks!

Mechanical switches depend on metal parts making physical contact. The problem with that is that the parts can actually bounce off one another. So instead of getting a circuit cleanly made it can in fact oscillate on-off-on-off-on before coming to rest.

This may happen, it may not. Even if it happens it may not be a problem depending on what the logic in the sketch does. If the software does some long task as soon as it “sees” the switch going on it does not matter if the switch actually bounces a bit. On the other hand if the software continuously montors the switch and only does something while the switch is on then bouncing will cause the task to start and stop quickly several times, which is probably undesirable.

It can be nasty if your switch does not bounce and so you don’t debounce it but then some time in the future the switch starts to bounce and your sketch has an obscure error it never had before.

There you go... that would be a situation I'd probably end up getting into.

OK, so debouncing it is... will look into that!

Thanks!

Debouncing is very simple, when a signal changes state you just allow some time to pass before accepting further changes (enough time to let the switch settle, which is not very long).

This is such a common requirement that there is existing code for it, but you might really benefit from writing your own.
Here is a tutorial

and here is a library
https://playground.arduino.cc/Code/Bounce

a common requirement so there is existing code to do