making a pause button
millenium_earl
Posts: 1
I am attempting to make a program that rotates a servo counterclockwise and then clockwise while it is turning counterclockwise 1 led will light up and when clockwise it will activate another led while turning off the previous one. My instructor had asked me to add a push button to it so it will pause when the button is pushed and then resume when i release it. I've been reading the "what's a microcontroller" and all i can do is make it reset, can someone help me please.
this is my code so far
' {$stamp BS2}
' {$pbasic 2.5}
counter VAR Word
DO
DEBUG "Counterclockwise green LED activated", CR
FOR counter = 500 TO 1000 STEP 10
PULSOUT 10, counter
PAUSE 7
HIGH 4
LOW 1
NEXT
DEBUG CR, "Clockwise red LED activated", CR
FOR counter = 1000 TO 500 STEP 10
PULSOUT 10, counter
PAUSE 7
HIGH 1
LOW 4
NEXT
LOOP UNTIL IN0 = 1
after this no matter what code i use It just resets.
this is my code so far
' {$stamp BS2}
' {$pbasic 2.5}
counter VAR Word
DO
DEBUG "Counterclockwise green LED activated", CR
FOR counter = 500 TO 1000 STEP 10
PULSOUT 10, counter
PAUSE 7
HIGH 4
LOW 1
NEXT
DEBUG CR, "Clockwise red LED activated", CR
FOR counter = 1000 TO 500 STEP 10
PULSOUT 10, counter
PAUSE 7
HIGH 1
LOW 4
NEXT
LOOP UNTIL IN0 = 1
after this no matter what code i use It just resets.
Comments
DO : LOOP WHILE IN2 = 0 ' This hangs if the pushbutton is pressed