Copyright © Parallax Inc.
Page 4 of 5
Note:
A servo can drain a fresh 9 V battery in less than 20 minutes. For tips on using a separate
power supply for a servo on the HomeWork Board, see the Parallax servos product pages (linked
below).
Propeller QuickStart
OBJ
SERVO : "Servo32v7.spin"
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
ServoCh1 = 0 ' Servo to pin 0
PUB Servo32_DEMO
SERVO.Start ' Start servo handler
repeat
' Syntax: SERVO.Set(Pin, Width)
SERVO.Set(ServoCh1,2000) ' 2000 usec
repeat 800000 ' Wait a short bit
SERVO.Set(ServoCh1,1000)
' 1000 usec
repeat 800000
SERVO.Set(ServoCh1,1500) ' 1500 usec (centered)
repeat 800000
Important!
Use a separate AA-size battery pack to power the servo. Connect as shown, being
sure not to mix up any of the wires. You can use alkaline or nickel metal hydride (NiMH) cells.
Note:
To use this program you must include the
program file. The Servo32v7 object is included in the download archive file. See the Using
Propeller Objects article (Learn.Parallax.Com > Support > References) for more information on
using Propeller object files.