Reference for Wiring version 0027+. 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()
{
// attaches a servo connected to pin 3
myservo.attach(3);
// attaches a servo connected to pin 15
mysecondservo.attach(15);
}
void loop()
{
// sets the servo position at 180 degrees
myservo.write(180);
// sets the servo position at 65 degrees
mysecondservo.write(65);
}
#include "Servo.h"
Servo myservo;
void setup()
{
// attaches a servo connected to pin 2
myservo.attach(2);
}
void loop()
{
// position the servo angle at 90 degrees
myservo.write(90);
} |
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 September 18, 2010 01:11:22am PDT