servo and two pushbuttons
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
' What's a Microcontroller - ReactionTimer.bs2[/SIZE][/FONT] [FONT=Calibri][SIZE=3]' Test reaction time with a pushbutton and a bicolor LED.[/SIZE][/FONT] [FONT=Calibri][SIZE=3]' {$STAMP BS2}[/SIZE][/FONT] [FONT=Calibri][SIZE=3]' {$PBASIC 2.5}[/SIZE][/FONT] [FONT=Calibri][SIZE=3]PAUSE 1000[/SIZE][/FONT] [FONT=Calibri][SIZE=3]timeCounter VAR Word[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DEBUG"Press andhold both pushbutton", CR,[/SIZE][/FONT] [FONT=Calibri][SIZE=3]"to makelight turn red.", CR, CR,[/SIZE][/FONT] [FONT=Calibri][SIZE=3]"Whenlight turns green, let", CR,[/SIZE][/FONT] [FONT=Calibri][SIZE=3]"go asfast as you can.", CR, CR[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DEBUG HOME, CR[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DEBUG IN3, CR[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DEBUG IN4, CR[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DO[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DO[/SIZE][/FONT] [FONT=Calibri][SIZE=3]LOOP UNTIL IN3 = 1AND IN4 = 1[/SIZE][/FONT] [FONT=Calibri][SIZE=3]HIGH 14[/SIZE][/FONT] [FONT=Calibri][SIZE=3]LOW 15[/SIZE][/FONT] [FONT=Calibri][SIZE=3]PAUSE 1000[/SIZE][/FONT] [FONT=Calibri][SIZE=3]LOW 14[/SIZE][/FONT] [FONT=Calibri][SIZE=3]HIGH 15[/SIZE][/FONT] [FONT=Calibri][SIZE=3]timeCounter = 0[/SIZE][/FONT] [FONT=Calibri][SIZE=3]timeCounter = 0[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DO[/SIZE][/FONT] [FONT=Calibri][SIZE=3]PAUSE 1[/SIZE][/FONT] [FONT=Calibri][SIZE=3]timeCounter =timeCounter + 1[/SIZE][/FONT] [FONT=Calibri][SIZE=3]LOOP UNTIL IN3 = 0OR IN4 = 0[/SIZE][/FONT] [FONT=Calibri][SIZE=3]LOW 15[/SIZE][/FONT] [FONT=Calibri][SIZE=3]DEBUG "Yourtime was ", DEC timeCounter,[/SIZE][/FONT] [FONT=Calibri][SIZE=3]" ms.",CR, CR,[/SIZE][/FONT] [FONT=Calibri][SIZE=3]"To play again,hold the ", CR,[/SIZE][/FONT] [FONT=Calibri][SIZE=3]"button downagain.", CR, CR[/SIZE][/FONT] [SIZE=3][FONT=Calibri]LOOP[/FONT][/SIZE] [FONT=Calibri][SIZE=3]