servo and two pushbuttons
axial28rr
Posts: 16
hello guys am new to this am learing parallax in my programing class one of the mini projects is to make a a servo go Clockwise and Counterwise with two push buttons. one button for ClockWise and another button for counter clockwise.
i was told i can modify this but i cant see to fish out the problem
this example id from what a microcontroler
' What's a Microcontroller - ServoControlWithPushbuttons.bs2
' Press and hold P4 pushbutton to rotate the servo counterclockwise,
' or press the pushbutton connected to P3 to rotate the servo clockwise.
' {$STAMP BS2}
' {$PBASIC 2.5}
duration VAR Word
duration = 750
PAUSE 1000
DO
IF IN3 = 1 THEN
IF duration > 500 THEN
duration = duration - 25
ENDIF
ENDIF
IF IN4 = 1 THEN
IF duration < 1000 THEN
duration = duration + 25
ENDIF
ENDIF
PULSOUT 14, duration
PAUSE 10
DEBUG HOME, DEC4 duration, " = duration"
LOOP
i was told i can modify this but i cant see to fish out the problem
this example id from what a microcontroler
' What's a Microcontroller - ServoControlWithPushbuttons.bs2
' Press and hold P4 pushbutton to rotate the servo counterclockwise,
' or press the pushbutton connected to P3 to rotate the servo clockwise.
' {$STAMP BS2}
' {$PBASIC 2.5}
duration VAR Word
duration = 750
PAUSE 1000
DO
IF IN3 = 1 THEN
IF duration > 500 THEN
duration = duration - 25
ENDIF
ENDIF
IF IN4 = 1 THEN
IF duration < 1000 THEN
duration = duration + 25
ENDIF
ENDIF
PULSOUT 14, duration
PAUSE 10
DEBUG HOME, DEC4 duration, " = duration"
LOOP
Comments
It's all done for you. What's not to love?
Check the wiring on your switches. Are you using pulldown resistors? P3 and P4 each need a ~10K resistor going to ground (Vdd), in addition to the switch that connects them to Vcc (5V).
Two Led recation timer with two push buttons so to start i used this program wich is from the hand out but only one is working. i need to be able to push both of the push buttons down and when i relese one of the push buttons it sends a time but i am only geting one to work any help on programing would be helpfull
' What's a Microcontroller - PushbuttonControlOfTwoLeds.bs2
' Blink P14 LED if P3 pushbutton is pressed, and blink P15 LED if
' P4 pushbutton is pressed.
' {$STAMP BS2}
' {$PBASIC 2.5}
PAUSE 1000
DO
DEBUG HOME
DEBUG ? IN4
DEBUG ? IN3
IF (IN3 = 1) AND (IN4 = 1) THEN
HIGH 14
HIGH 15
PAUSE 50
ELSEIF (IN3 = 1) THEN
HIGH 14
PAUSE 50
ELSEIF (IN4 = 1) THEN
HIGH 15
PAUSE 50
ELSE
PAUSE 50
ENDIF
LOW 14
LOW 15
PAUSE 50
LOOP
Thanks Ax