Aborting a PAUSE
Lightfoot
Posts: 228
I have a very simple program that turns an LED on and off. I want the program to immediately stop if a switch on RA.2 is pushed. If I do it this way (see below) it may take one second to exit the loop. I want the RA.2 input to even override a pause command.
plp_a = 0
DO WHILE RA.2 = 1
RA.0 = ~RA.0
pause 1000
LOOP
rb = %00111100
Thanks
Post Edited By Moderator (Bean (Hitt Consulting)) : 7/29/2007 10:03:59 PM GMT
plp_a = 0
DO WHILE RA.2 = 1
RA.0 = ~RA.0
pause 1000
LOOP
rb = %00111100
Thanks
Post Edited By Moderator (Bean (Hitt Consulting)) : 7/29/2007 10:03:59 PM GMT
Comments
This checks the abort button 20 times per second, instead of once per second as with your code.
Connected to the RB port is another SX that dies the PWM command.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
NOTE this isn't actual code
main:
if btn_a = 1 then mode = mode+1
if btn_b = 1 then goto THEEND
if mode => maxmode then mode=0
if mode = 0 gosub loopa
if mode = 1 gosub loopb
if mode = 2 gosub loopc
goto main
loopa:
turn output on
return
loopb:
if delaytemp = maxdelay then toggle output
if delaytemp = maxdelay then delaytemp = 0
delaytemp = delaytemp + 1
return
etc
If your just flashing a led why not
a pushbutton· +· resistor + flashing led all in series
············································ led that flashes by itself..
··············································|\
·+
·PushB·
[noparse][[/noparse]·resistor]
| ||----· -
············································· |/
Or a 555 timer astable with a reset button wired to pin 4
Ronald Nollet