Reference for Wiring version 0023+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.
| Name |
Servo |
| Examples |
#include "Servo.h"
Servo myservo;
Servo mysecondservo;
void setup() {
myservo.attach(3) // attaches a servo connected to pin 3
mysecondservo.attach(15) // attaches a servo connected to pin 15
}
void loop() {
myservo.write(180); // sets the servo position at 180 degrees
mysecondservo.write(65); // sets the servo position at 65 degrees
}
#include "Servo.h"
Servo myservo;
void setup() {
myservo.attach(2) // attaches a servo connected to pin 2
}
void loop() {
myservo.write(90); // position the servo angle at 90 degrees
} |
| Description |
Class for controlling servo motors connected to the Wiring I/O pins. |
| Syntax |
Servo myservo; |
| Methods |
| attach() |
Attaches a servo motor to an i/o pin |
| detach() |
Stops an attached servos from pulsing its i/o pin |
| read() |
Gets the last written servo pulse width as an angle between 0 and 180 |
| write() |
Sets the servo angle in degrees |
| attached() |
Returns true if there is a servo attached |
| readMicroseconds() |
Gets the last written servo pulse width in microseconds |
| writeMicroseconds() |
Sets the servo pulse width in microseconds |
|
| Returns |
None |
| Usage |
Application |
Updated on November 01, 2009 08:28:39am PST