How to pause a servo motor in the middle location.
I was wondering how I can make a servo motor stop midway,pause for a second or so then continue all the way to one side then come back,pause for a second or so midway, then continue all the way in other direction.I would like to continue this action where the servo turns one way then the other way in which it pauses for a second or so every time it is in the middle.Thank you all for your help.

Comments
this should be close its a newer version http://www.parallax.com/Portals/0/Downloads/docs/prod/edu/28123-WAM-v3.0.pdf
Use 1000 for Counter Clockwise, than 750 for Center, then 500 for clockwise, then 750 for center. (750 will always return to center)
Rinse repeat.
for b0=500 to 1000 step 1
pulsout 1,b0
pause 20
next
then try step 2 or anything larger. And obviously you could stop mistroke using
for b0=500 to 750
etc....
' {$STAMP BS2}
' {$PBASIC 2.0}
x VAR Word
OUTPUT 14
here:
FOR x = 1 TO 100
PULSOUT 14, 250
PAUSE 10
NEXT
PAUSE 500
FOR x = 1 TO 100
PULSOUT 14, 750
PAUSE 10
NEXT
PAUSE 1000
FOR x = 1 TO 100
PULSOUT 14, 1090
PAUSE 10
NEXT
PAUSE 500
FOR x = 1 TO 100
PULSOUT 14, 750
PAUSE 10
NEXT
PAUSE 1000
GOTO here
The following code should perform exactly as before except the servo will hold position better.
' {$STAMP BS2} ' {$PBASIC 2.0} x VAR Word DO FOR x = 1 TO 75 PULSOUT 14, 250 PAUSE 19 NEXT FOR x = 1 TO 100 PULSOUT 14, 750 PAUSE 19 NEXT FOR x = 1 TO 75 PULSOUT 14, 1090 PAUSE 19 NEXT FOR x = 1 TO 200 PULSOUT 14, 750 PAUSE 19 NEXT LOOP' {$STAMP BS2} ' {$PBASIC 2.0} x VAR Word 'a variable called x one word long here: 'a label FOR x = 1 TO 75 'beginning of a for...next loop for how long the servo is held at a location (270) PULSOUT 14, 270 'the pin (P14) that sends out the postion(270) for the servo to stop at the far right PAUSE 19 'pause 19 ms NEXT 'if x has reached 75 at this stage,the program will continue FOR x = 1 TO 100 'beginning of a for...next loop for how long the servo is held at a location(750) PULSOUT 14, 750 'the pin (P14) that sends out the postion(750)for the servo to stop in the middle PAUSE 19 'pause 19 ms NEXT 'if x has reached 100 at this stage,the program will continue FOR x = 1 TO 75 'beginning of a for...next loop for how long the servo is held at a location(1160) PULSOUT 14, 1160 'the pin (P14) that sends out the postion(1160)for the servo to stop at the far left PAUSE 19 'pause 19 ms NEXT 'if x has reached 75 at this stage,the program will continue FOR x = 1 TO 100 'beginning of a for...next loop for how long the servo is held at a location(750) PULSOUT 14, 750 'the pin (P14) that sends out the postion(750)FOR the servo TO STOP in the middle PAUSE 19 'pause 19 ms NEXT 'if x has reached 100 at this stage,the program will continue GOTO here 'go back to the here label to do it all again' {$STAMP BS2} ' {$PBASIC 2.0} x VAR Word 'a variable called x one word long here: 'a label FOR x = 1 TO 100 'beginning of a for...next loop for how long the servo is held at a location (270) PULSOUT 14, 270 'the pin (P14) that sends out the postion(270) for the servo to stop at the far right PAUSE 19 'pause 19 ms NEXT 'if x has reached 100 at this stage,the program will continue FOR x = 1 TO 100 'beginning of a for...next loop for how long the servo is held at a location(750) PULSOUT 14, 750 'the pin (P14) that sends out the postion(750)for the servo to stop in the middle PAUSE 19 'pause 19 ms NEXT 'if x has reached 100 at this stage,the program will continue FOR x = 1 TO 100 'beginning of a for...next loop for how long the servo is held at a location(270) PULSOUT 14, 270 'the pin (P14 that sends out the postion (270)for the servo to stop at the far right. PAUSE 19 'pause 19 ms NEXT 'if x has reached 100 at this stage,the program will continue FOR x = 1 TO 100 'beginning of a for...next loop for how long the servo is held at a location (1150) PULSOUT 14, 1150 'the pin (P14) that sends out the postion (1150)for the servo to stop at the far right PAUSE 19 'apuse 19 ms NEXT 'if x has reached 100 at this stage,the program will continue GOTO here 'go back to the here label to do it all againTry to avoid using GOTO. DO..LOOP will accomplish what you need.
You might want to try subroutines next.
Partial example;
' {$STAMP BS2} ' {$PBASIC 2.0} x VAR Word 'a variable called x one word long DO GOSUB LEFT GOSUB CENTER GOSUB RIGHT GOSUB CENTER LOOP LEFT: FOR x = 1 TO 75 'beginning of a for...next loop for how long the servo is held at a location (270) PULSOUT 14, 270 'the pin (P14) that sends out the postion(270) for the servo to stop at the far right PAUSE 19 'pause 19 ms NEXT 'if x has reached 75 at this stage,the program will continue RETURN RIGHT: enter code here RETURN CENTER: enter code here RETURNThis is more advanced than what you are talking about but it works like a charm. You can run a servo and in the pauses of the servo run sonar like PING. The pauses may need to be increased by a couple ms but it will not be visually noticeable and will not affect the speed of your code. So instead of saying Pause 19 you might say Pause 20 or Pause 21.
My sonar was not a PING and ran a bit slower than PING and the servo loop could easily handle the timing.