
Copyright © Parallax Inc.
Page 8 of 8
Demonstration Program
#include <Servo.h>
Servo myServo; // Create Servo object to control the servo
void setup() {
myServo.attach(9); // Servo is connected to digital pin 9
}
void loop() {
myServo.writeMicroseconds(1700); // Counter clockwise
delay(2000); // Wait 2 seconds
myServo.writeMicroseconds(1300); // Clockwise
delay(2000);
myServo.writeMicroseconds(1500); // Stop
delay(2000);
}
Note:
These sketches use the Servo library, which is included with the Arduino IDE software.
For More Information
•
See the
Continuous Rotation Servo (#900
store page for full documentation.
•
You may substitute the
if you want a regular R/C servo
motor that turns onl
y in a limited arc. Use the following pulse widths to control the motor:
o
1000 μs: Turn clockwise
o
1500 μs: Center
o
2000 μs: Turn counterclockwise
•
The product pages for
the standard and continuous rotation servos provide downloads for the
full product documen
tation and wiring diagrams for separate power supplies.
•
Several Parallax development and education boards provide integrated 3-pin headers for easy
connecting to servos
(either 4 or 6 headers, depending on the board).
These products
Parallax Board of Education (BASIC Stamp 2)