Push button controller
Kojanow
Posts: 2
I am making a project with two servo's and two pushbuttons, one to acuate each servo.· The servo's are moving fine but I can't get teh push buttons to control them.
This what I have· HELP!
·' {$STAMP BS2}
' {$PBASIC 2.5}
counter·· VAR·· Word
pulses··· VAR·· Word
duration· VAR·· Word
Main:
·IF (IN2 = 1) THEN
·HIGH 0
·PAUSE 50
·LOW 0
·PAUSE 50
·ENDIF
·DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 750
PAUSE 20
NEXT
DEBUG "Clockwise 2 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 150
PAUSE 20
NEXT
DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 750
PAUSE 20
NEXT
DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 08, 750
PAUSE 20
NEXT
DEBUG "Clockwise 2 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 08, 150
PAUSE 20
NEXT
DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 08, 750
PAUSE 20
NEXT
DO
LOOP
This what I have· HELP!
·' {$STAMP BS2}
' {$PBASIC 2.5}
counter·· VAR·· Word
pulses··· VAR·· Word
duration· VAR·· Word
Main:
·IF (IN2 = 1) THEN
·HIGH 0
·PAUSE 50
·LOW 0
·PAUSE 50
·ENDIF
·DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 750
PAUSE 20
NEXT
DEBUG "Clockwise 2 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 150
PAUSE 20
NEXT
DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 15, 750
PAUSE 20
NEXT
DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 08, 750
PAUSE 20
NEXT
DEBUG "Clockwise 2 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 08, 150
PAUSE 20
NEXT
DEBUG "Counterclockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 08, 750
PAUSE 20
NEXT
DO
LOOP
Comments
Are you starting with What's a Microcontroller, Chapter 4, Activity #4? It shows how to use two pushbuttons and one servo, one pushbutton makes it turn one way, the other pushbutton makes it turn the other way.
The important thing is to have your pushbutton state trigger an action. In the program above, your if-then statement for your pushbutton (if it is connected to P3) only causes P0 to turn on and off once. There is no relationship to your servos on P8 and P15.
Stephanie
Eric
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support