Page 1 of 1

Button... Controll Menu Question

Posted: Sat Feb 04, 2012 6:43 pm
by Jordy101091
Hi all,

Im working on my rewrite of my aquarium controller, Im currently working on the menu and want to use one button for entering and exiting from the menu.
I want to do this by using a short press to go to the next item of the menu and a longer press (2sec) to exit the menu.

I dont know how to go around this, maybe you can help.

Regards Jordy

Re: Button... Controll Menu Question

Posted: Sat Feb 04, 2012 8:16 pm
by medelec35
Hi Jordy,

There are a few ways of doing this.
Attached is what I believe is the simplest way using one button.
There may be other ways of course.

I could create a flowchart using several buttons, but will be more complex

Flowchart will also eliminate issues caused by contact bounce.

Martin

Re: Button... Controll Menu Question

Posted: Sun Feb 05, 2012 9:13 pm
by medelec35
I have added 2 more switches.
So now you can short press or long press any combination simultaneously.
I have mapped switches with keys 0 to 2.
so
Key 0 will control switch connected to A0
Key 1 will control switch connected to A1
and Key 2 will control switch connected to A2
You can also have a combination as stated earlier.
E.g press keys 0 and 1 and keep held for a second for long press A0 & A1
or press keys 1 and 2 and release key 2 for short press A1 and long press A2 etc.
So now you can have 24 menus from just 3 switches (if I have worked it out correctly, prob not :lol: )

Re: Button... Controll Menu Question

Posted: Mon Feb 06, 2012 12:43 am
by medelec35
This version works much better on hardware with more than one switch pressed simultaneously.

Re: Button... Controll Menu Question

Posted: Mon Feb 06, 2012 9:19 pm
by Jordy101091
Thanks Martin you are a genius.
It helped me a lot.
Thanks

Re: Button... Controll Menu Question

Posted: Tue Feb 07, 2012 12:02 am
by medelec35
Thanks Jordy,
Glad the code has helped you.

Martin