DC Motors not always running upon start of Arduino

Hi!
My project is basically taking in a Bluetooth signal of a single value, based on which it will run the required motors to open or close a compartment of a water filter.

I am currently using an Arduino Uno, a Motor Shield L293D and a Bluetooth module hc05 to do this project.

Originally, I tried using the below code to run the project, however, the motors would never run, only buzz, unless I physically moved them. I had connected 4 double a batteries to the external power, and increased it all the way until I had 12 double a batteries to the external power, with the same result.

The Bluetooth module worked fine, and the code was fine to my knowledge, as the motors buzzing matched up to what I had them running as based on the code. All the motors work when connected to a single double a battery without the arduino, so the motors are not faulty.

The motors are only supposed to run one at a time, and the module only takes between 3.6 to 6V, so I assumed that in all, I would only need 9V or 10V, yet I don't get the proper output. The end result is that these motors should roll a string to lift up the edge of a 3d printed compartment about 3 by 5 inches, so relatively light, but for that I need this to run.

Below is my code for the original project, and my (poorly drawn) schematic.

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

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
char value = ' ';

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
   if (Serial.available()>0) { //If connected {
   value = Serial.read();
   }
   switch (value) {
    case '0': {
      motor1.setSpeed(250); //0 to 255 speed settings
      motor1.run(FORWARD);
      delay(1000); //in milliseconds
      motor1.run(BACKWARD);
      delay(1000);
      motor1.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '1': {
      motor1.setSpeed(250); //0 to 255 speed settings
      motor1.run(FORWARD);
      delay(1250); //in milliseconds
      motor1.run(BACKWARD);
      delay(1250);
      motor1.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '2': {
      motor1.setSpeed(250); //0 to 255 speed settings
      motor1.run(FORWARD);
      delay(1500); //in milliseconds
      motor1.run(BACKWARD);
      delay(1500);
      motor1.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '3': {
      motor1.setSpeed(250); //0 to 255 speed settings
      motor1.run(FORWARD);
      delay(1750); //in milliseconds
      motor1.run(BACKWARD);
      delay(1750);
      motor1.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '4': {
      motor2.setSpeed(250); //0 to 255 speed settings
      motor2.run(FORWARD);
      delay(2000); //in milliseconds
      motor2.run(BACKWARD);
      delay(2000);
      motor2.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '5': {
      motor2.setSpeed(250); //0 to 255 speed settings
      motor2.run(FORWARD);
      delay(1000); //in milliseconds
      motor2.run(BACKWARD);
      delay(1000);
      motor2.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '6': {
      motor2.setSpeed(250); //0 to 255 speed settings
      motor2.run(FORWARD);
      delay(1250); //in milliseconds
      motor2.run(BACKWARD);
      delay(1250);
      motor2.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '7': {
      motor2.setSpeed(250); //0 to 255 speed settings
      motor2.run(FORWARD);
      delay(1500); //in milliseconds
      motor2.run(BACKWARD);
      delay(1500);
      motor2.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '8': {
      motor2.setSpeed(250); //0 to 255 speed settings
      motor2.run(FORWARD);
      delay(1750); //in milliseconds
      motor2.run(BACKWARD);
      delay(1750);
      motor2.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    }
    case '9':
      motor2.setSpeed(250); //0 to 255 speed settings
      motor2.run(FORWARD);
      delay(2000); //in milliseconds
      motor2.run(BACKWARD);
      delay(2000);
      motor2.run(RELEASE);
      motor3.setSpeed(100);
      motor3.run(FORWARD);
      delay(2000);
      motor3.run(RELEASE);
      break;
    case '-': //if the app sends the default value - this is for testing
      Serial.println("Not a recognized value.");
    default:
    break;
    
  }
  value = ' ';
}

This morning, I decided to strip the entire project and just had one connected motor and 6 double a batteries connected to the external power source, with a USB connected to my laptop powering the arduino (so two different power sources). The motor works when twisted, but now, it does not buzz. It does work sometimes upon the power being connected to the arduino, but not always.

Any advice? What am I doing wrong?

Motors used:

Motor Shield:

If there is any other information necessary, please let me know and I will add it as soon as I see it, or if I need to switch out any parts for better results, any guidance would be helpful. Thank you so much!!!

I'd say whatever your problem was, it is now having to deal with a damaged L293 board.
Instructions say a max input of 10 volts ( 12-AA's =18volts at least)

https://www.amazon.com/HiLetgo-Driver-Shield-Compatible-Duemilanove/dp/B01DG61YRM

  • Using this chip you can use DC motors and power supplies of up to 10 Volts, that some pretty big motors and the chip can supply a maximum current of 600mA per channel.

I think on the website, it is a little higher, about 12 V, but I do realize what you are saying - I looked at a different spec sheet by accident, that one said up to 36 V total. Either way though, it wasn't working in the first place, so I would like to see if we can resolve that and see if it might work anyway if possible. Do you have any ideas?

Test the board with a simpler load. Like an LED with resistor. Back to back LEDs could show motor direction also.

What is the diameter of the spool that is winding the string? How fast should the edge be lifted? How much weight is being lifted, how far? I'm thinking you need a gearmotor.
Gearmotors
110RPM gearmotor

You supplied the link to the board....I only showed what they said were the limitations, in this case 10 volt....my point being, if there was a problem it's now burried in a dodgy damaged board......
Anyhow, follow what Aarg suggests.....

That is what I was trying with the single motor this morning, but while it is starting sometimes, but not all the time without external spinning of the shaft. It does spin continuously after spinning it once though.

Did you try connecting them directly to the power source, bypassing all the electronics?

Literally is just on the motor, and currently it is not even holding that, I am just testing with plain motors. As far as how fast, it truly doesn't matter. The goal of the project is to drop a certain amount of mineral which I was coding with hard values of trying to find the sweet spot, so as long as it opens and closes, I should be fine despite speed.

Yes, and they do work just fine.

Please post clear images of your actual hardware.

That says the tiny, high speed motor does not have nearly the starting torque required.
What is the diameter of the spool that is winding the string?
How much weight is being lifted, how far?


The one motor is connected in the picture, the other two wires are not connected to anything. Currently, the motor starts off at high speed and decreases to 0 over about a minute.

Post a picture of the mechanism please.

There is no spool -- it will wind on the shaft itself with a small ring of solder to prevent it falling out of the shaft - we might add this later, but first we want this to work. The weight would probably be around a 5 grams. It will hold the compartment closed, and will lower the opening about 3 cm to let a bit of the mineral fall, and then close again.

What does the battery voltage look like while that is going on? Do the motor driver IC's get hot?

10V of double A batteries.

This is without the mechanism that it isn't working. I will add the mechanism once the basics start working, but that is currently with my partner.

MEASURED voltage while it runs, not what is written on them... :frowning:

It is over 9V when measured, but below 12V, which is why I said around 10V. The motors receive less than 1.5 V however. The ICs do get hot.