Need Help running three items at once (parallel)

I am building a small motion controll device for my camera.
I have successfully got the three different axis’ working with arduino

What I can’t figure out for the life of me is how to run all three at the same time.
I can only get them to run one after the other.

Here are the three codes.

This one is for the Stepper (tracking):

#include <AFMotor.h>

AF_Stepper motor(200, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Stepper test!”);

motor.setSpeed(50); // 50 rpm

motor.step(300, FORWARD, SINGLE); // check forward and reverse before running into problems
motor.release(); //
delay(1000);
}

void loop() {
}

This one is for the servo (pan):

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

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

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object

for(pos = 30; pos < 130; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(100); // waits 15ms for the servo to reach the position
}
for(pos = 130; pos>=30; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(100); // waits 15ms for the servo to reach the position
}
}

void loop()
{
}

and this one is for the servo (tilt):

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

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

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object

for(pos = 70; pos < 150; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(100); // waits 15ms for the servo to reach the position
}
for(pos = 150; pos>=70; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(100); // waits 15ms for the servo to reach the position
}

Any help would be greatly appreciated! I have been sorta stuck on this for a month or so.
Thank you.

As soon as I'm done with this MC Rig, I will post a video of the machine working. As well as practice footage from it.

You need to think in iterations, not in complete actions. Remember, to run a servo from 30 to 130 is the same as incrementing the servo with just 1, a hundred times.

Divide your sketches into functions that when called many times will do the complete action. This way you can work on multiple motors at the same time.

You could use this library for so doing: http://www.arduino.cc/playground/Code/TimedAction It will periodically call a function with millisecond presicion. It need to be polled (asked if it is time to do a certain action) but it is rarely a problem if you design your incremental functions right.

I'm such an idiot. I don't really understand. I'm going to have to get someone to help me write it.

I get what you're saying, but I haven't the slightest idea how to write the code for this.

I'd be willing to pay if someone has the time. Maybe videochat about it.