Hi Rob,
If you want the button to enable/disable the blining LED then you can't toggle the LED itself in the interrupt and then just continue to blink it in the main program loop. What you need is flag or semaphore telling the main loop if the LED is supposed to blink or not.
Code:
BLINK VAR BIT
ON INTERRUPT GOTO int1
main:
If Blink = 1 THEN
HIGH LED
PAUSE 500
LOW LED
PAUSE 500
ENDIF
GOTO main
DISABLE
int1:
Blink = !Blink ' Invert the state of the semapore
RESUME
ENABLE
Please note that the PAUSE statement is basically delaying the Int1 routine from executing until the PAUSE statement finishes (that's the drawback of ON INTERRUPT). So if you push the button just as the PAUSE 500 start to exectute the ISR won't execute until 500ms later. This won't matter in this case but please keep that in mind when you start doing more complicated stuff.
Also, the above does not incorporate any debounce, you may want to add that.
/Henrik.
Bookmarks