
Copyright © Parallax Inc.
Page 3 of 5
Program KickStarts
Each of the example programs turns the servo counter clockwise, then clockwise, and finally to
the center position. This movement is repeated indefinitely.
Important!
Servo motors draw only minimal current when they’re not attached to a mechanical
load, such as the leg of a robot. The example connection diagrams shown here provide only
modest current to the servo, so they are not intended to move heavy loads. They’re useful for
demonstration only. To operate bigger loads the servo motor should be connected to its own 4.8
V to 6 V battery supply. See the links below for information on how to use separate power to
operate one or more R/C servo motors.
BASIC Stamp 2 HomeWork Board
'{$STAMP BS2}
'{$PBASIC 2.5}
counter VAR Word
Main:
FOR counter = 1 TO 100 ' Loop for 2 seconds
PULSOUT 0, 1000 ' Servo counterclockwise
PAUSE 20
NEXT
FOR counter = 1 TO 100 ' Loop for 2 seconds
PULSOUT 0, 500 ' Servo clockwise
PAUSE 20
NEXT
FOR counter = 1 TO 100 ' Loop for 2 seconds
PULSOUT 0, 750 ' Servo center
PAUSE 20
NEXT
GOTO Main