Controling multiple servos indepentently need help with coding

Hey Forum, i am working on a project where i require multiple servos to move at different paces but also to move at different times. I am able to have all the servos move simultaneously but not one after the other.

here is my code so far:

#include <Servo.h>

Servo myservo; // create servo object to control a servo
Servo myservoa;
Servo myservob;// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(8);
myservoa.attach(9);
myservob.attach(10); // attaches the servo on pin 9 to the servo object
}

void loop()
{
for(pos = 0; pos <= 15; pos += 15) // goes from 0 degrees to 15 degrees
{ // in steps of 15 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(50);

myservoa.write(pos);

myservob.write(pos);
delay(50); // waits 15ms for the servo to reach the position
}
for(pos = 15; pos>=0; pos-=15) // goes from 15 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(50);
myservoa.write(pos);

myservob.write(pos);
delay(50); // waits 50ms for the servo to reach the position
}
}

If you put all three servo.write() in the same for-loop and use the same loop variable for all three that are going to all move in the same way at the same time. To have different servos moving at different speeds and times you need to give up on the delay() loops for timing and use the millis() function to determine if it is time to move a servo, which servo, and how much to move.

Read this post and the first reply for details about how to get your Arduino to act like it is doing several separate tasks at the same time: Demonstration code for several things at the same time - Project Guidance - Arduino Forum