Can not run all 4 motors at the same time

Dear Experts,

I have no background in coding for Arduino but I am learning.
I have built a car with 4 DC motors and L293D motor shield stacked on Arduino board.
I am stuck with the parameters initialisation and simple test code to run all 4 motors clockwise.

If anyone can help me get started with the setup, I will be learn other functions.

Thanks !

First you’ll need to give a link to the datasheet or other info about your un-named L293 shield.

It is rather difficult to help you with your code if we can’t see it. Please read the “how to use the forum” stickies to see how to format and post code and information on what we need to know to be able to help you.

I am able to run only a single motor M1. As soon as I used two motors, I hear only
humming noise and no wheel rotates.

Here is my code.

#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

void setup() {
  Serial.begin(9600);
  // turn on motor
  delay(5000);
  //motor1.setSpeed(90);
  //motor2.setSpeed(90);
  //motor3.setSpeed(90);
  //motor4.setSpeed(90);
  
//  motor1.run(RELEASE);
//  motor2.run(RELEASE);
//  motor3.run(RELEASE);
//  motor4.run(RELEASE);

  
}
void loop() {
  
//Motor1
motor1.run(FORWARD);
motor1.setSpeed(150); 

motor2.run(FORWARD);
motor2.setSpeed(150); 
/*motor3.run(FORWARD);
motor3.setSpeed(150); 
motor4.run(FORWARD);
motor4.setSpeed(150); 
delay(2000);

motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
delay(5000);

/*
motor1.run(BACKWARD);
motor1.setSpeed(120); 
delay(2000);
motor1.run(RELEASE);
delay(1000);

//Motor2
delay(2000);
delay(1000);
motor2.run(BACKWARD);
motor2.setSpeed(120); 
delay(2000);
motor2.run(RELEASE);
delay(1000);

//Motor3
delay(2000);
delay(1000);
motor3.run(BACKWARD);
motor3.setSpeed(120); 
delay(2000);
motor3.run(RELEASE);
delay(1000);

//Motor4
delay(2000);
delay(1000);
motor4.run(BACKWARD);
motor4.setSpeed(120); 
delay(2000);
motor4.run(RELEASE);
delay(1000);
*/
}

From where does the shield get the power to drive the motors? It sounds like it may not be enough.

I have a separate 9 volt power supply for shield.

Not a 9 volt smoke alarm battery, I hope?

If you swap the motor connections, can you always power one motor, whichever channel you use?

Yes it is 9 volt smoke alarm battery

Put it back in the smoke alarm, and get six AAs.

Thanks a lot. I tried giving second motor a manual boost and it started rotating with M1. So seems it is getting less power...

Yeah that makes sense, since the stall current required to get a motor going is way higher than that needed to keep it going

6 AA's worked instead of smoke alarm 9 volt type ! Thanks a lot.