Arduino Uno
#include <Servo.h>
Servo myServo;
void setup() {
myServo.attach(9);
}
void loop() {
myServo.write(180);
delay(2000);
myServo.write(0);
delay(2000);
myServo.write(90);
delay(2000);
}
Note: This sketch uses the Servo library, which is included with the Arduino IDE software.
For More Information
Refer to the
Parallax Standard Servo (#900-00005) Product Documentation
•
information.
You may substitute the
•
that keeps turning, such as drive wheels on a robot. Note that code may require modification.
The product pages for the standard and continuous rotation servos provide downloads for the
•
full product documentation 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 are
the
Parallax Board of Education (BASIC Stamp
Propeller Board of
Copyright © Parallax Inc.
// Use Servo library, included with IDE
// Create Servo object to control the servo
// Servo is connected to digital pin 9
// Rotate servo counter clockwise
// Wait 2 seconds
// Rotate servo clockwise
// Rotate servo to center
Parallax Continuous Rotation Servo (#900-00008)
Education, and
Propeller Activity Board
2),
Board of Education Shield (for
WX.
for additional
if you want a motor
Arduino),
Page 5 of 5