two dc motors

I have two dc motors running off adafruit motor shield. I want the motors to operate in parallel, independent of each other, so far it just runs sequentially as a loop tends to do. How can i get the two motors to run at the same time in their own loops?

Any help, much appreciated.

#include <AFMotor.h>

AF_DCMotor motor(1, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");

motor.setSpeed(255); // set the speed to 200/255
motor2.setSpeed(255);
}

void loop() {

//Serial.print("tick");

motor2.run(FORWARD);
delay(350);
motor2.run(BACKWARD);
delay(250);
motor2.run(RELEASE);
delay(2000);

motor.run(FORWARD); // turn it on going forward
delay(200);
//Serial.print("tock");
motor.run(BACKWARD); // the other way
delay(130);
//Serial.print("tack");
motor.run(RELEASE); // stopped
delay(3000);

}

Have a look at the "blink without delay" tutorial and see if you can adapt it to your needs.

would be intrested to see what code you end up using, i am having the same issue.

I found one way of solving this problem on my adafruit sheild. heres what I fumbled together so far.
#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

//2.Create the AF_DCMotor object with AF_DCMotor(motor#, frequency), to setup the motor H-bridge and latches. The constructor takes two arguments.
//The first is which port the motor is connected to, 1, 2, 3 or 4.
//frequency is how fast the speed controlling signal is.
//For motors 1 and 2 you can choose MOTOR12_64KHZ, MOTOR12_8KHZ, MOTOR12_2KHZ, or MOTOR12_1KHZ. A high speed like 64KHz wont be audible but a low speed like 1KHz will use less power. Motors 3 & 4 are only possible to run at 1KHz and will ignore any setting given

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");

motor1.setSpeed(200); // set the speed to 200/255
motor2.setSpeed(200); // set the speed to 200/255
}

void loop() {
Serial.print("tick");

motor1.run(FORWARD);
motor2.run(FORWARD); // turn it on going forward
delay(10000);

motor1.run(FORWARD);
motor2.setSpeed(100);
motor2.run(FORWARD); // turn it on going forward
delay(10000);

motor1.run(FORWARD);
motor2.setSpeed(200);
motor2.run(FORWARD); // turn it on going forward
delay(10000);

motor1.run(FORWARD);
motor2.setSpeed(100);
motor2.run(FORWARD); // turn it on going forward
delay(10000);

Serial.print("tack");
motor1.run(RELEASE);
motor2.run(RELEASE); // stopped
delay(10000);

motor1.run(FORWARD);
motor2.run(FORWARD); // turn it on going forward
delay(10000);

motor1.run(FORWARD);
motor2.run(FORWARD); // turn it on going forward
delay(10000);

Serial.print("tock");
motor1.run(BACKWARD);
motor2.run(BACKWARD); // the other way
delay(10000);

Serial.print("tack");
motor1.run(RELEASE);
motor2.run(RELEASE); // stopped
delay(10000);
}

thats a long loop but I hope you get the idea.