Rotate servo program
Hi Stampers
Can you chack the following program, it is to rotate a servo and disply 1 or 2;
it is close to one of the examples but not working well:
'{$STAMP BS2}
' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
' Send messages to the BASIC Stamp to control a Bridge using
' the Debug Terminal and 7-Segments display location.
' {$PBASIC 2.5}
counter VAR Word
pulses VAR Word
duration VAR Word
OUTH = %00000000 'outh initialized to low.
DIRH = %11111111 'set P8-P15
DO
'main
routine.
DO
DEBUG "Enter 1000 to rotate Bridge:", CR
DEBUGIN DEC duration
IF duration < 1000 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
IF duration > 1000 THEN
DEBUG "You must typr 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
LOOP UNTIL duration > 999 AND duration < 1001
DEBUG "BRIDGE is rotating...", CR
FOR counter = 1 TO pulses
PULSOUT 7, 1000
PAUSE 20
NEXT
DEBUG "BRIDGE IN FLOWER HALL (1)"
PAUSE 1000
GOSUB TURN1
DO
DEBUG "Enter 1000 to rotate Bridge:", CR
DEBUGIN DEC duration
IF duration < 500 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
IF duration > 1000 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
LOOP UNTIL duration > 999 AND duration < 1001
DEBUG "BRIDGE is rotating...", CR
FOR counter = 1 TO pulses
PULSOUT 7, 1000
PAUSE 20
NEXT
DEBUG "BRIDGE IN ROCK HALL (2)"
PAUSE 1000
GOSUB TURN2
LOOP
' Subroutines
TURN1:
OUTH = %10000100 '1
PAUSE 1000
RETURN
TURN2:
OUTH = %11010011 '2
PAUSE 1000
RETURN
Thank you all
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway - Enter today
[noparse][[/noparse]Non-text portions of this message have been removed]
Can you chack the following program, it is to rotate a servo and disply 1 or 2;
it is close to one of the examples but not working well:
'{$STAMP BS2}
' What's a Microcontroller - RotateBridgeUsingDebugTerminal.bs2
' Send messages to the BASIC Stamp to control a Bridge using
' the Debug Terminal and 7-Segments display location.
' {$PBASIC 2.5}
counter VAR Word
pulses VAR Word
duration VAR Word
OUTH = %00000000 'outh initialized to low.
DIRH = %11111111 'set P8-P15
DO
'main
routine.
DO
DEBUG "Enter 1000 to rotate Bridge:", CR
DEBUGIN DEC duration
IF duration < 1000 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
IF duration > 1000 THEN
DEBUG "You must typr 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
LOOP UNTIL duration > 999 AND duration < 1001
DEBUG "BRIDGE is rotating...", CR
FOR counter = 1 TO pulses
PULSOUT 7, 1000
PAUSE 20
NEXT
DEBUG "BRIDGE IN FLOWER HALL (1)"
PAUSE 1000
GOSUB TURN1
DO
DEBUG "Enter 1000 to rotate Bridge:", CR
DEBUGIN DEC duration
IF duration < 500 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
IF duration > 1000 THEN
DEBUG "You must type 1000 to rotate the BRIDGE", CR
PAUSE 1000
ENDIF
LOOP UNTIL duration > 999 AND duration < 1001
DEBUG "BRIDGE is rotating...", CR
FOR counter = 1 TO pulses
PULSOUT 7, 1000
PAUSE 20
NEXT
DEBUG "BRIDGE IN ROCK HALL (2)"
PAUSE 1000
GOSUB TURN2
LOOP
' Subroutines
TURN1:
OUTH = %10000100 '1
PAUSE 1000
RETURN
TURN2:
OUTH = %11010011 '2
PAUSE 1000
RETURN
Thank you all
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway - Enter today
[noparse][[/noparse]Non-text portions of this message have been removed]