Making two DC motors run simultaneously

Why is that when i program the two motors to run, one runs first and then the other runs. How do I eliminate this time lag and make them run simultaneously? I'm using the adafruit motor shield V1.

Please tell me how to write the code to make them run at the same time with no time lag.

Why is that when i program the two motors to run, one runs first and then the other runs

Because you've programmed it that way

How do I eliminate this time lag and make them run simultaneously?

change your code

Please tell me how to write the code to make them run at the same time with no time lag.

By posting your code so we know what you are doing wrong.

My crystal ball says that the problem is on line 42 of the code that was not posted.

Remove the delays() you have in your code that we don't see and study multiple things at the same time

This happens when the Straight() function is called

int const RS = A0; // Right sensor connected to pin A0
int const LS= A3;  // Left sensor connected to pin A3

#include <AFMotor.h>
AF_DCMotor r_motor(3); // Right motor connected to port 3
AF_DCMotor l_motor(4); // Left motor connected to port 4

void setup(){
  Serial.begin(9600);
  pinMode(RS, INPUT); 
  pinMode(LS, INPUT);
  //Intitializing pin A0 and A3 as inputs
 }

void loop(){

  bool r_state = digitalRead(A0);
  bool l_state = digitalRead(A3);
  

      if((r_state == false) && (l_state == false)){
        Straight();
      }
       if((r_state == true) && (l_state == false)){
        Turn_Right();
      }
       if((l_state == true) && (r_state == false)){
        Turn_Left();
      }
       if(l_state && r_state  ){
        Stop();
      }
 
}

void Straight(){
    l_motor.setSpeed(200);
    r_motor.setSpeed(200);
    
  }
void Turn_Right(){
   
      r_motor.setSpeed(200);
      l_motor.setSpeed(200);
      r_motor.run(FORWARD);
      l_motor.run(BACKWARD); 
   }
void Turn_Left(){

    l_motor.setSpeed(200);  
    r_motor.setSpeed(200);
    l_motor.run(FORWARD);
    r_motor.run(BACKWARD);
}
void Stop(){
    l_motor.setSpeed(0);
    r_motor.setSpeed(0);
    r_motor.run(RELEASE);
    l_motor.run(RELEASE);
}

What does your power wiring look like?

Also noticed that when the Straight Function is called the left wheel moves forward and the right wheel moves backwards. Although this happens the Turn_Right and Turn_Left functions work perfectly. Can anyone explain this

What is the point of defining LS and RS, but using A0 and A3 ?

AWOL:
What does your power wiring look like?

this

mandax_25:
Also noticed that when the Straight Function is called the left wheel moves forward and the right wheel moves backwards. Although this happens the Turn_Right and Turn_Left functions work perfectly. Can anyone explain this

That's because you miss

l_motor.run(FORWARD);
r_motor.run(FORWARD);

In the Straight Function

vaj4088:
What is the point of defining LS and RS, but using A0 and A3 ?

I'm using the adafruit motor shield(v1).... that's why I've used the analog pins as digital ins

Using analog pins as digital pins is fine, BUT...

if you are going to define LS and RS, then A0 and A3 should not appear elsewhere in the code. It defeats the purpose of defining LS and RS.