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

attach()

Examples
#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 The Wiring servo motor library provides for 24 servo channels, so it can drive up to 24 servo motors at a time. A servomotor signal cable can be connected to any digital I/O pin on the Wiring I/O board. The attach(pin) method attaches a Servo variable to the pin where the servo is connected. The attach(pin, min, max) method attaches to a pin setting min and max values in microseconds default min is 544, max is 2400. Up to 24 Servo objects can be attached at the same time.
Syntax
servo.attach(pin)
servo.attach(pin, min, max)
Parameters
servo Any variable of type Servo
pin Any Wiring hardware I/O pin
min min value in microseconds
max max value in microseconds
Returns None
Usage Application
Updated on July 07, 2011 11:11:30pm PDT

Creative Commons License