L293D shield not providing enough power

So I got an L293D shield attached to 2 DC motors, and the problem is that only one of those can move without any 'help'. When I try to move both motors, I need to manually push the wheel connected to the DC motor to make them go. The Arduino board(UNO btw) is currently connected to my laptop. How do I fix this problem?

#include <SoftwareSerial.h>
#include <AFMotor.h>

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
SoftwareSerial Bluetooth(2,4);


char c=' ';
char cb=' ';
int k=0;

void setup() {
  Serial.begin(9600);
  Serial.println("ready");
  Bluetooth.begin(38400);
  motor1.setSpeed(255);
  motor1.run(RELEASE);
  motor2.setSpeed(255);
  motor2.run(RELEASE);
}
char inputs[5] = {'N','N','N','N','N'};  
int move=0;
int dir=0;
int lr=0;

void loop() {


  if(Bluetooth.available()) {
    cb=c;
    c=Bluetooth.read();
    Serial.write(c);
    if(cb==c) {
      k++;
      if(k>=10 && inputs[4]!=c) {
        for(int j=0; j<4; j++) {
          inputs[j]=inputs[j+1];
        }
        inputs[4]=c;
      }
    }
    else {
      k=0;
    }
    if(inputs[4]=='N' && inputs[3]=='T' && inputs[2]=='O' && inputs[1]=='N') {
      Serial.write("AAAAAAA");
      if(move==0) {
        motor1.run(FORWARD);
        motor2.run(FORWARD);
        move=1;
        dir=0;
      }
      else if(move==1) {
        motor1.run(RELEASE);
        motor2.run(RELEASE);
        move=0;
      }
      for(int i=0; i<5; i++) {
        inputs[i]='N';
      }
    }
    if(inputs[4]=='N' && inputs[3]=='O' && inputs[2]=='N') {
      if(dir==1 && move==1){
        motor1.run(FORWARD);
        motor2.run(FORWARD);
        dir=0;
      }
      else if(dir==0 && move==1) {
        motor1.run(BACKWARD);
        motor2.run(BACKWARD);
        dir=1;
      }
      for(int i=0; i<5; i++) {
        inputs[i]='N';
      }
    }
    if(inputs[4]=='O' && inputs[3]=='T'&& inputs[2]=='O') {
      if(lr==0 || lr==1) {
        motor1.setSpeed(100);
        lr=-1;
      }
      else if(lr==-1) {
        motor1.setSpeed(200);
        lr=0;
      }
      for(int i=0; i<5; i++) {
        inputs[i]='N';
      }
    }
    if(inputs[4]=='N' && inputs[3]=='T' && inputs[2]=='N') {
      if(lr==-1 || lr==0) {
        motor2.setSpeed(100);
        lr=1;
      }
      else if(lr=1) {
        motor2.setSpeed(200);
        lr=0;
      }
      for(int i=0; i<5; i++) {
        inputs[i]='N';
      }
    }

    for(int i=0; i<5; i++) {
      Serial.write(inputs[i]);
    }
    Serial.write(" ");
    Serial.print(move);
    Serial.write(" ");
    Serial.print(dir);
    Serial.write(" ");
    Serial.print(lr);
    Serial.write("\n");
  }

}

here's the code

and these are the wheels and the motors that I'm using:

Where is the power to the motors coming from ?

I have the Arduino UNO connected to my laptop via USB cable and mounted an L293D motor shield on top of it. There are no other power sources.

You cannot sensibly power those motors from USB because of the current required. They need an external power supply

Another issue: USB is 5V.
With L293D you loose 2V..
Only 3V left...
Try 9V for the motors. L293D has 2 power connections. One for 5V (for the inside controller) and another to feed the motors (can take higher voltage).
5V can be taken from arduino.

But not from a PP3 battery

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.