I'd like to create the following program: each time I press a button, a variable takes the next value among these values: 3, 11, 19, 49, 68, 75, and then it goes back to 3 and so on...
OldSteve:
That's pretty much what I meant, Paul, but worded it very poorly.
You need to do more to debounce the input than just detect the state change because, by definition, if/when the switch bounces it will produce several state changes.
UKHeliBob:
You need to do more to debounce the input than just detect the state change because, by definition, if/when the switch bounces it will produce several state changes.
When I said I worded it poorly, I meant that I should have used more words to describe the situation better - debounce the actual press and detect the state changes.
Depending on the program, a simple delay can even do the job, without further code. (And you get auto-repeat for free.)