Chapter 2: Your Boe-Bot’s Servo Motors
· Page 77
You can use ServoP13Clockwise.bs2 to send this pulse train to the servo connected to
P13.
Example Program: ServoP13Clockwise.bs2
Your entire system, including servos should be connected to power for this activity.
√
If you have a Board of Education Rev C, set the 3-position switch to position-2.
This connects power to the servo ports in addition to the position-1 power to the
BASIC Stamp, Vdd, Vin, and Vss.
√
If you have a BASIC Stamp HomeWork Board, replace the battery you removed
from the battery pack. This will restore power to the servo ports. Also, connect
the 9 V battery to the battery clip. This will supply power to the embedded BASIC
Stamp, Vdd, Vin, and Vss.
√
Enter, save, and run ServoP13Clockwise.bs2.
√
Verify that the servo’s horn is rotating between 50 and 60 RPM clockwise.
' Robotics with the Boe-Bot – ServoP13Clockwise.bs2
' Run the servo connected to P13 at full speed clockwise.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
DO
PULSOUT 13, 650
PAUSE 20
LOOP
Notice that a 1.3 ms pulse requires a
PULSOUT
command
Duration
argument of 650,
which is less than 750. All pulse widths less than 1.5 ms, and therefore
PULSOUT
Duration
arguments less than 750, will cause the servo to rotate clockwise.
Example Program: ServoP12Clockwise.bs2
By changing the
PULSOUT
command’s
Pin
argument from 13 to 12, you can make the
servo connected to P12 turn full speed clockwise.
√
Save ServoP13Clockwise.bs2 as ServoP12Clockwise.bs2.
√
Modify the program by updating the comments and the
PULSOUT
command’s
Pin
argument to 12.