To understand what would work best for you try downloading the Pickit 1 user's guide from Microchip. Also grab the lessons code there, which has the assembly or C code. You could try the finite state machine, watchdog timer, or interrupt examples.
The state machine example is not exactly immediate, but easiest to implement, it would look something like:
#define button PortA.0
dir button in
WPUA0 = 1 ;enable weak pullup
...
...
counter = 0
WatchButton:
If button Off Then ;check for button press
wait 10 ms ;debounce button
If button On Then goto WatchButton ;glitch so start over
counter += 1 ;this is an incrementing example, could be a variable, or?
If counter = 3 Then counter = 1 ;check for last case+1 and start over
End if
Select Case counter
Case 1
(Do something)
Case 2
(Do something)
End Select
wait X ms ;determine necessary wait period
goto WatchButton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
how do i make a pin change in state immediatly cause a change in what sub routine is running?
16f685
To understand what would work best for you try downloading the Pickit 1 user's guide from Microchip. Also grab the lessons code there, which has the assembly or C code. You could try the finite state machine, watchdog timer, or interrupt examples.
The state machine example is not exactly immediate, but easiest to implement, it would look something like:
#define button PortA.0
dir button in
WPUA0 = 1 ;enable weak pullup
...
...
counter = 0
WatchButton:
If button Off Then ;check for button press
wait 10 ms ;debounce button
If button On Then goto WatchButton ;glitch so start over
counter += 1 ;this is an incrementing example, could be a variable, or?
If counter = 3 Then counter = 1 ;check for last case+1 and start over
End if
Select Case counter
Case 1
(Do something)
Case 2
(Do something)
End Select
wait X ms ;determine necessary wait period
goto WatchButton