Electronics Projects: How to Use FOR Loops in PBASIC Code
Electronics Components: Introducing the BASIC Stamp
Electronics Projects: How to Connect a Push Button to a BASIC Stamp

Electronics Projects: How to Use a Servo in a Circuit

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.

image0.jpg
' 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
DO
 IF SW1 = 1 THEN
  Position = 500
 ENDIF
 IF SW2 = 1 THEN
  Position = 1000
 ENDIF
 PULSOUT Servo, Position
 PAUSE 20
LOOP

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.

image1.jpg image2.jpg
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Electronics Projects: How to Connect a Servo to a BASIC Stamp
Electronics Projects: How to Use DO Loops in PBASIC Code
Electronics Projects: How to Create Names in PBASIC Code
Electronics Components: Buying a BASIC Stamp
Electronics Projects: How to Program Music on a BASIC Stamp
Advertisement

Inside Dummies.com