I am trying to use analog multiple switches for multiple function
as
i have 5 buttons on analogpin 0
which returns
left 0
up 1
down 2
right 3
select 4
i want to use select button to change the behaviour of reset of four buttons
i.e if select count is 1
they behave as menu driver moveup, movedown, moveleft, moveright
if select count is 2
they behave as cursor moveup,down left right
if count 3
the buttons increase or decrease the selected value
To do this, you'll have to decide how the select button works - does pressing it go through the three states in order, or do you hold it down to go to a special state, etc?
For example, if you pressed the button repeatedly to cycle through the states, then code like this would take care of the state switch:
int selectButtonState=1;
...later on...
If (selectButtonPressedSomehow())
{
selectButtonState=selectButtonState+1;
if (selectButtonState>3)
selectButtonState=1;
}
...later on...
if (1==selectButtonState)
{
// do menu driver moveup, movedown, moveleft, moveright
}
if (2==selectButtonState)
{
// dos cursor moveup,down left right
}
if (3==selectButtonState)
{
// do buttons increase or decrease the selected value
}
(note the code can be shorter - this is just to illustrate how to do it simply)
The end result is your select button can have the others do three different states per button