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

writeMicroseconds()

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 0 degrees
  myservo.writeMicroseconds(544);
}

#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.writeMicroseconds(2400);  
}
Description The writeMicroseconds(ms) method sets Sets the servo pulse width in microseconds.
Syntax
servo.writeMicroseconds(ms)
Parameters
servo Any variable of type Servo
ms int: the pulse width in microseconds
Returns None
Usage Application
Updated on July 07, 2011 11:11:32pm PDT

Creative Commons License