Sure it can be done with interrupts but here's something to try...
Code:
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
GPIO = 0
TRISIO = %11111110
ANSEL = 0
CMCON = 7
LED var GPIO.0
PushButton var GPIO.1
Delay var byte
CounterA var Byte
MaxCount con 100
pause 100
Start:
if pushbutton=0 then
while pushbutton=0 : wend
pause 50
Gosub Routine1
endif
goto start
Routine1:
for countera=0 to maxcount
toggle led
GOSUB DoDelay
next
return
DoDelay:
for delay=0 to 50
pause 10
if pushbutton=0 then
while pushbutton=0 : wend
pause 50
delay=50
countera=maxcount
led=0
endif
next
return
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks