button question
Nick
Posts: 11
a while back i saw a post that explained how to have a single button do multiple things ie. the first time you press it it did x. the second it did y, and the third it did z. anyone seen this post, or know how to do it?
I have a keypad that is interfaced to the stamp via serial. and i would like to be able to 'scroll' through commands with one button on the keypad.
Thanks
I have a keypad that is interfaced to the stamp via serial. and i would like to be able to 'scroll' through commands with one button on the keypad.
Thanks
Comments
Assuming you need no more than 16 tasks based on the next button press....
- You will need to de-bounce the button contact. There is plenty of documentation on how to do that
- Set up a nibble variable to act as a counter
Before the button is pressed the first time,·initialize your counterEach time the button is pressed, increment the counter by one
Depending on the counter value, call the subroutine that you want to occur.
After the last event occurs,·re-initialize your counter
EX;
You want to do 4 subroutines, call them sub1, sub2, sub3, sub4 (but you will use more usefull names).
The example below is by no means complete, but I hope you see the big picture to help you get started.
Post Edited (KenM) : 5/1/2005 2:59:49 PM GMT