Electronics Projects: How to Use a Servo in a Circuit - dummies

Electronics Projects: How to Use a Servo in a Circuit

By Doug Lowe

A servo is a special type of motor for use in electronics that is designed to rotate to a particular position and hold that position until told to rotate to a different position. Hobby servos are frequently used in radio-controlled vehicles such as airplanes, boats, and cars, but there are many other uses for servos.

This project shows you how to build a complete circuit that uses a servo as well as two pushbuttons. This circuit can run the following program.


' Servo Control Program
' Doug Lowe
' July 15, 2011
' This program moves a servo to one of two when SW1 is pressed
' and returns the servo to center position when SW2 is pressed.
' {$STAMP BS2}
' {$PBASIC 2.5}
Servo PIN 0
SW1  PIN 14
SW2  PIN 10
Position VAR Word
Position = 500
 IF SW1 = 1 THEN
  Position = 500
 IF SW2 = 1 THEN
  Position = 1000
 PULSOUT Servo, Position

For projects that require multiple servos or a lot of other work besides managing the servo, you should consider using Parallax’s Propeller chip instead of a BASIC Stamp. The Propeller processor is designed for programs that have to do several things at once, such as managing servos.

The propeller costs a little more than a BASIC Stamp and its programming language is a little more complicated, but in the end, controlling multiple servos is much easier with a Propeller than with a BASIC Stamp.