I know what you are saying, hopefully this will clarify.
Code:
Clear
DEFINE OSC 20
DEFINE LOADER_USED 1
ADCON1 = %00001111
' ---------- [ I/O Definition ] ----------
TRISA = %00000001 ' Set PORTA to all input
TRISB = %10000001 ' Set PORTB (0)INPUT (1-5)OUTPUTS
TRISC = %01000111 ' Set PORTC (0-2 input) rest Outputs
PORTB = 0
Switch VAR PORTC.0 ' use a pin with Schmitt Trigger input
Presses VAR BYTE
RedLED VAR PORTB.1
X VAR BYTE
LOOP VAR BYTE
Main:
if Switch = 1 THEN
WHILE Switch = 1 : WEND
COUNT Switch, 1500, Presses
BRANCHL Presses,[routine1, routine2, routine3]
GOTO MAIN
endif
GOTO Main
'--------------
routine0: ' button was not pressed again
' or pressed more than 3 times
GOTO Main
'--------------
routine1: ' pressed once
HIGH REDled
PAUSE 500
LOW REDled
GOSUB CheckButton
GOTO Main
'--------------
routine2: ' pressed twice
FOR X = 1 TO 2
HIGH REDled
PAUSE 500
LOW REDled
PAUSE 500
NEXT X
GOSUB CheckButton
GOTO Main
'--------------
routine3: ' pressed thrice
FOR X = 1 TO 3
HIGH REDled
PAUSE 500
LOW REDled
PAUSE 500
NEXT X
GOSUB CheckButton
GOTO Main
Flash:
For loop = 1 to 10
Red = 1
Pause 50
Red = 0
Pause 50
Next Loop
Return
Confirmation:
Return
Once the Switch has been pushed a number of time 1, 2 or 3, it then jumps to the routine. It is then within this routine that it looks for the confirmation Button push after the LED has flashed it corresponding number of times by going to the Confirmation subroutine.
Hope this makes sense.
Steve
Bookmarks