This would still require some kind of debouncing. The logic state can "bounce" a number of times when pressing a button
Contact's debouncing should be solved with proper RC filter! If proper filtering is not possible an additional IF/THEN statement should reduce greatly the debouncing effect.
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
IF KEYPRESS = False THEN KeyFlag = True ' re-checks the key logic state
ENDIF
.
.
.
.
.
GOTO LOOP
Al.
Last edited by aratti; - 26th July 2010 at 00:01.
All progress began with an idea
Bookmarks