Reference for Wiring version 0024+. 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.

Class

Servo

Name

write()

Examples
#include "Servo.h"

Servo myservo;

void setup() {
  myservo.attach(2)   // attaches a servo connected to pin 2 
}

void loop() {
  myservo.write(90);  // sets the servo position at 90 degrees
}

#include "Servo.h"

Servo myservo;

void setup() {
  myservo.attach(3)     // attaches a servo connected to pin 3 
}

void loop() {
  myservo.write(180);  // sets the servo position at 180 degrees
}
Description The write(degrees) method sets the position of the servo to the degrees specified. Servos can be positioned between 0 and 180 degrees. An invalid angle that is valid as pulse in microseconds is treated as microseconds.
Syntax
servo.write(degrees)
Parameters
servo Any variable of type Servo
degrees Any integer value between 0 and 180
Returns None
Usage Application
Updated on November 01, 2009 08:34:33am PST

Creative Commons License