Hello everyone, again!
This time I'm wondering if there is any way to have an event(like a button press) interrupt the code and go to a line label at any time?
The problem with my code is that the controller only checks for the button press after that pause. That pretty much means that you have to hold down the button to get the right timing in order for the moving LEDs to switch direction(which is what my code is about). So is there any way to interrupt the program at ANY time and then point it at a line label to continue there?
this is my code:
Code:
x var byte
switch var bit
TRISA = 1
TRISC = 0
switch = 1
mainloop:
x = 1
loop:
PORTC = x
pause 500
if switch = 1 then
if PORTA.3 = 0 then
switch = ~switch
goto loop
endif
if x == 8 then
goto mainloop
else
x = x << 1
goto loop
endif
else
if PORTA.3 = 0 then
switch = ~switch
goto loop
endif
if x == 1 then
x = 8
goto loop
else
x = x >> 1
goto loop
endif
endif
Bookmarks