Libraries \ Servo

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Class

Servo

Name

write()

Examples
#include "Servo.h"

Servo myservo;

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

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

#include "Servo.h"

Servo myservo;

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

void loop() {
  // sets the servo position at 180 degrees
  myservo.write(180);  
}
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 July 07, 2011 11:11:31pm PDT

Creative Commons License