I have a piece of code at the moment that indexes through a series of displays using the Switch/Case method and a simple debounced push button.
At the moment I have it setup so that when it reaches case 11 it resets to case 0, however, I've been trying to get my head around a 'simple' way to make in go backwards and forwards through the index instead..
To try and clarify my question, using my current code, when I press the push button I get:
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3.... etc...
What I would like to achieve is:
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4... etc..
I've been playing with having a boolean flag that starts true and therefore a button press causes button_index++, when button_index > 10 set the flag to false so therefore a button press causes button_index-- and so on and so forth..
I'm just struggling to work out how to make it loop continuously..