if i remove the pauses, there's no debounce, and one push of a button cycles through alot of menus.
I would apply a flag condition to control the key state.
Code:
False CON 0
True CON 1
KEYPRESS VAR portXx
KeyFlag VAR BIT
Counter VAR WORD
LOOP:
PAUSE 1
IF KEYPRESS = False then
IF KeyFlag = False Then
Counter = Counter + 1
KeyFlag = True
ENDIF
ELSE
KeyFlag = False
ENDIF
.
.
.
.
.
GOTO LOOP
In the above snippet every time you press the key "KEYPRESS" the word variable "Counter" will increment of one unit, no matter how long you keep the key down. If you remove the flag control using pauses, it will be rather complicate to reach the same results.
Al.
Last edited by aratti; - 25th July 2010 at 16:12.
All progress began with an idea
Bookmarks