I posted questions regarding a motor driver 18v15 a couple of days ago and I got problems solved.
However, I ran into another problem using this motor driver.

I had 2 motors running fine with switches and these are connected to motor driver boards (6-24VDC Brush Motor
6A continuous 25A peak) . The motors do not turn unless a switch is activated through Arduino.

I added a third motor using the motor driver (18v15) from Pololu.
I did not add any switches on this one and programmed it so that it constantly runs, changing directions every 5 seconds.
The 2 motors that were working stopped responding. I looked at the Serial Monitor and I found out that Arduino is reading too slow. I see four 0s maybe in 30-40 secs. and then it stops for a minute or two. I had the switches read analog values so I changed it to digitalRead and it does not change the speed that Arduino reads the input pins.

Can you tell me why this is happening? I can’t tell if it is a programming issue or a hardware issue.
Thank you so much for your help in advance.

int Unit1switchPin = 4;
int Unit1switchPin2 = 5;
int Unit2switchPin = 2;
int Unit2switchPin2 = 3;
int Unit1switchVal = 0;
int Unit1switchVal2 = 0;
int Unit2switchVal = 0;
int Unit2switchVal2 = 0;
int pwmPin = 9 ;
int dirPin = 8;

// output pins
#define U1L1 10
#define U1H2 10
#define U1L2 11
#define U1H1 11
#define U2L1 12
#define U2H2 12
#define U2L2 13
#define U2H1 13

void setup(){
  pinMode(Unit1switchPin, INPUT);
  pinMode(Unit1switchPin2, INPUT);
  pinMode(Unit2switchPin, INPUT);
  pinMode(Unit2switchPin2, INPUT);
    // motor stuff   
  pinMode(pwmPin, OUTPUT); 
  pinMode(dirPin, OUTPUT); 
  digitalWrite(pwmPin, HIGH);

void loop(){
  Unit1switchVal = digitalRead(Unit1switchPin);
  Unit1switchVal2 = digitalRead(Unit1switchPin2);
  Unit2switchVal = analogRead(Unit2switchPin);
  Unit2switchVal2 = analogRead(Unit2switchPin2);
  if(Unit1switchVal == 1){

  if(Unit1switchVal2 == 1){
  if(Unit1switchVal == 0 && Unit1switchVal == 0){
  if(Unit2switchVal > 500 && Unit2switchVal2 < 500){

  if(Unit2switchVal2 > 500 && Unit2switchVal < 500){
  if(Unit2switchVal > 500 && Unit2switchVal2 >500){
  digitalWrite(dirPin, LOW);

  digitalWrite(dirPin, HIGH);

// motor movement - self explained function names 
void motor_forward () {  


void motor_stop () {

void motor_reverse () { 

void Unit2_motor_forward () {  


void Unit2_motor_stop () {

void Unit2_motor_reverse () { 

Why do you think that the analog readings are causing your code to be slow? Those readings are going to take way less time than your two calls to delay(5000).

I don’t know why your program stops after a minute or two, but maybe if you add more serial println’s you can figure out what the CPU is doing during that time.


So, I tried it again with 18v15 motor driver from pololu and another one listed above. Arduino reads slow again. It seems like whenever I add the motor driver from pololu, it reads slow. Is it possible that wiring of the board slows down the reading?
I am only using 3 pins, pwm (driver) to pwm pin(arduino), dir (driver) to the digital pin (arduino) and gnd ( driver) to the gnd of arduino.

And, what kind of serial println do I need to do to see the activities of the CPU?

Thank you so much for reading such a long post!

No. Did you read my comment about “delay(5000)” in my last post? I’ll elaborate on that: What slows down your reading is that you added two calls to “delay(5000)” in your loop function in order to make your motor change direction every 5 seconds. Each call to delay(5000) will take 5 seconds to complete and during that time none of the other code in your loop function can run, including the code that does the analog readings.

In general, (unless you are using interrupts or an OS), computer programs execute each line of code in sequence, and they don’t execute the next line of code until the current one is complete.

If you want your Arduino to appear as if it is performing multiple tasks at once, then you must avoid calling functions that take a long time to finish, (such as delay). So try replacing your delay-based code with this:

if ((millis() % 10000) < 5000)
  digitalWrite(dirPin, LOW);
  digitalWrite(dirPin, HIGH);

Note: I don’t know when the millis() return value overflows and wraps around; you might see some bad behavior when that happens.

Does this make sense to you?


I got rid of the delay and replaced it with the code you provided.

it works slightly better but weird things still happen.
For example, a motor connected to the pololu motor driver responds to a button connected to a different motor driver.

I noticed that the 5v from arduino to the motor driver boards drop to 4.2v when more than one button is pressed. Is this normal?
Does this mean that it is drawing too much current, more current than Arduino can handle?

Should the v+ on the logic side be connected to the 5v as well? I am not talking about the 5vOUT.

Thanks again.

What does “responds” mean in this case? Also what do you mean by “button connected to a different motor driver”?

This is probably an issue with your power supply. How are you powering the motors and the Arduino? What happens to the Arduino’s input voltage during the time that the +5V line is at 4.2V?

If none of these checks yields clues, then simplify your system (start removing buttons, motor drivers, and code) to the simplest possible thing that should work, but doesn’t. Then post a description of that system here, including code, wiring, picture, and the expected and actual behavior.

No. The V+ pad on the logic side is equal to the V+ pad on the motor side, where you should have your motor power supply connected. If you connect V+ to 5V then you are shorting your motor power to 5V and you might break something.


Ok. Maybe I should have explained the setup I have more in detail.
I have three motor drivers connected to Arduino.
Two are not from Pololu which has 6-24V, 6A cont 25A peak direct control.
I have two switches per driver so that when one button is pressed, it sets the movement forward and when the other one is pressed, the direction changes. The two drivers work fine until I add the third driver which is the Pololu 18v15. When I press a button from one of the drivers, the motor attached to that driver as well as the motor attached to the Pololu motor turns. This is what I meant by the pololu motor driver responds to a button connected to a different motor driver. I added a button to the Pololu motor driver, but it doesn’t even print to the serial monitor (the button is not read).

The Arduino is powered by the laptop and the motors are powered by an external power supply (12v 14A). Each motor completely locks at 2.4A so I figured 14A should be sufficient to power all 5 of them.

I am not sure how to measure this, given that I powered Arudino through my laptop. I also tried powering Arduino with 12v external power supply, not the one that powers the motors, but a different one. But this didn’t seem to make a difference in terms of the performance, other than the fact that there is a less voltage drop when a button is pressed. It goes down from 5v to 4.8v.

I will try to do this, but my problem seems to only occurs when I try to connect the Pololu motor driver to Arudino with another motor driver.

Thank you so much for your help! :slight_smile:

Oh, and one more thing, I should ground the GND on the logic side to Arduino GND, correct?

The first part of this sentence makes it sound like you are either did something unusual or you are not correctly communicating what you did. Did you really “add a button to the Pololu motor driver”, or did you actually connect a button to your Arduino and write some code to read the state of the button and control the Pololu motor driver?

The second part of the sentence is not clear either. What do you mean by “it doesn’t even print to the serial monitor”? Does it mean that you added a Serial.println statement to debug the state of the button but its output is not showing up in the serial monitor? What is the expected behavior of the button and the serial monitor? What is the actual behavior of the button and the serial monitor?

It’s very likely that there is something wrong with your code if the Pololu motor driver is activating when you press a button. Try simplifying your code to the simplest possible program that should not activate the Pololu motor driver, but does. A good way to start simplifying your code would be to remove all code relating to the Pololu motor driver. In the process of simplifying your code you should be able to discover what caused the 18v15 to activate when you didn’t want it to.

Correct, you should ground the GND on the logic side to Arduino GND.