Question about pause command until a condition happens
Kenm5261
Posts: 1
In my bs1 program, I want to pause or stop the program from looping for a 10 seconds unless an input comes on. If the input comes on i want to jump to a different routine. Can I do this??
Would it be easier to write a for loop with a counter that would check every second to see if the input has come on, then jump to the different routine?
Override:
LOW 6
Pause 10000
GOTO Main
This is the subroutine I have. I forgot that I have to check an input while its paused and if this input comes on i have to goto main. It can switch over in a second, it doesnt have to switch in a millisecond or anything.
Would it be easier to write a for loop with a counter that would check every second to see if the input has come on, then jump to the different routine?
Override:
LOW 6
Pause 10000
GOTO Main
This is the subroutine I have. I forgot that I have to check an input while its paused and if this input comes on i have to goto main. It can switch over in a second, it doesnt have to switch in a millisecond or anything.
Comments
LOW 6
FOR x = 1 to 10000
IF Input = True THEN GOTO Elsewhere
Next
GOTO Main
Elsewhere:
Perform "Different routine"
I don't know how long it would take the For Next loop to run, but this code will let you check for an input during your waiting period.
Delay:
· IF timer = 0 THEN Delay_Exit···· ' exit if timer expired
··· PAUSE 100······················'·delay 0.1 sec
··· timer = timer - 1············· ' update timer
··· IF Override = No THEN Delay··· ' keep going unless override input active
Delay_Exit:
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax