Simultaneous but different servo sweeps with four servos

here is another way to do it; using the slow speed modification to the servo library discussed in this thread: http://arduino.cc/forum/index.php/topic,61586.0.html

// speed controlled Servo Sweep
// see: http://arduino.cc/forum/index.php/topic,61586.0.html
//
// Michael Margolis 4 August 2011

#include <VarSpeedServo.h>

const int NBR_SERVOS = 4;       // the number of servos

VarSpeedServo Servos[NBR_SERVOS];        // servo objects


int servoPins[NBR_SERVOS]        = {8,     9,  10,  11}; // servo pins
int servoSpeeds[NBR_SERVOS]      = {1,    10, 100, 255}; // sweep speed, 1 is slowest, 255 fastest)
int servoMinPosition[NBR_SERVOS] = {10,   20,  30,  40}; // the minumum servo angle
int servoMaxPosition[NBR_SERVOS] = {120, 130, 140, 150}; // the maximum servo angle

void setup()
{
   for(int i=0; i < NBR_SERVOS; i++)  
   {
     Servos[i].attach(servoPins[i]);       
     Servos[i].slowmove(servoMinPosition[i],servoSpeeds[i]) ; // start sweeping from min position
   }
}

void loop()
{
  // sweep the servos
  for(int i=0; i < NBR_SERVOS; i++)
  {    
     if( Servos[i].read() == servoMinPosition[i])
       Servos[i].slowmove(servoMaxPosition[i],servoSpeeds[i]) ;         
     else if( Servos[i].read() == servoMaxPosition[i])
       Servos[i].slowmove(servoMinPosition[i],servoSpeeds[i]) ;           
  }  
}