| Index

| Reference for Wiring 1.0 (ALPHA) 0017+. 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 |  | ### attach()
Examples |  |
    #include <Servo.h>

    Servo myservo;

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

    void loop() {
      myservo.write(90);  // position the servo angle at 90 degrees
    }
    #include <Servo.h>

    Servo myservo;
    Servo mysecondservo;

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

    void loop() {
      myservo.write(180);      // sets the servo position at 180 degrees
      mysecondservo.write(65); // sets the servo position at 65 degrees
    }
Description |  | The Wiring servo motor library provides for 8 servo channels, so it can drive up to 8 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. Up to 8 Servo objects can be attached at the same time.
Syntax |  |
    servo.attach(pin)
Parameters |  |
servo |  | Any variable of type Servo
pin |  | Any Wiring I/O pin
Returns |  | None
Usage |  | Application