ServoMultiple \ Learning \ Wiring ALPHA 1.0
Author: Hernando Barragán
Description: Wiring is an electronic sketchbook and hardware electronics for developing ideas. It is a context for learning fundamentals of computer programming and prototyping with electronics within the context of the electronic arts.
Keywords: Wiring, Processing, Interactive Media, Electronic Arts, Programming, C, C++, Hernando Barragán

Search wiring.org.co:

This example is for Wiring version 0024+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

Driving multiple servos by BARRAGAN
Demonstrates the use of the servo library to drive two servo motors. It positions two generic servo motors at 0, 90 and 180 degrees.

    #include <Servo.h>

    Servo myservo0;  // create servo object to control a servo
    Servo myservo1;  // create another servo object to control another servo

    void setup()
    {
      myservo0.attach(0);  // attaches the servo on pin 0 to the servo object
      myservo1.attach(1);  // attaches the servo on pin 1 to the other servo object
    }

    void loop()
    {
      myservo0.write(0);    // position first servo at 0 degrees
      myservo1.write(0);    // position second servo at 0 degrees
      delay(1000);          // wait for the servos to reach the desired position
      myservo0.write(90);   // at 90 degrees
      myservo1.write(90);
      delay(500);
      myservo0.write(180);  // at 180 degrees
      myservo1.write(180);
      delay(500);
    }