Shop OBEX P1 Docs P2 Docs Learn Events
making a pause button — Parallax Forums

making a pause button

millenium_earlmillenium_earl Posts: 1
edited 2011-10-12 12:11 in BASIC Stamp
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.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-12 12:11
    Assuming that the pushbutton is connected to I/O pin 2 and it's wired to provide a low input when pushed ... (See the What's a Microcontroller? tutorial for examples of this)

    DO : LOOP WHILE IN2 = 0 ' This hangs if the pushbutton is pressed
Sign In or Register to comment.