Rotating servo with pushbutton
hmiller
Posts: 17
Hi,
I've been working on this for a while now and i can't find a thread that gives me an answer.
So I was wondering if someone knew the answer for a simple fix.
I have my servo plugged in and the button plugged in. I know they both work because when i run a code and the servo rotates and when i push my button it stops. I want the total opposite, I want it so that when i push the button, the continuous servo runs for as long as i say it too and then stops, and I want this to keep repeating so that if someone pushes it again it will do the same over and over.
Here's the two codes that i'm trying to use from the book "what's a microcontroller":
Code 1:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN1
counter VAR Word
DO
IF (IN1 = 1) THEN
DEBUG "Vending...", CR
FOR counter = 1 TO 150
PULSOUT 2, 1000
PAUSE 20
NEXT
DEBUG "Thank you!"
ELSE
PAUSE 100
ENDIF
LOOP
Code 2:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN1
counter VAR Word
IF IN1 = 1 THEN
DEBUG "Vending...", CR
FOR counter = 1 TO 150
PULSOUT 2, 1000
PAUSE 20
NEXT
DEBUG "Thank you!", CR
ENDIF
Please help!
I've been working on this for a while now and i can't find a thread that gives me an answer.
So I was wondering if someone knew the answer for a simple fix.
I have my servo plugged in and the button plugged in. I know they both work because when i run a code and the servo rotates and when i push my button it stops. I want the total opposite, I want it so that when i push the button, the continuous servo runs for as long as i say it too and then stops, and I want this to keep repeating so that if someone pushes it again it will do the same over and over.
Here's the two codes that i'm trying to use from the book "what's a microcontroller":
Code 1:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN1
counter VAR Word
DO
IF (IN1 = 1) THEN
DEBUG "Vending...", CR
FOR counter = 1 TO 150
PULSOUT 2, 1000
PAUSE 20
NEXT
DEBUG "Thank you!"
ELSE
PAUSE 100
ENDIF
LOOP
Code 2:
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN1
counter VAR Word
IF IN1 = 1 THEN
DEBUG "Vending...", CR
FOR counter = 1 TO 150
PULSOUT 2, 1000
PAUSE 20
NEXT
DEBUG "Thank you!", CR
ENDIF
Please help!
Comments