Arduino keeps restarting with L9110 and DC motor

I'm trying to control a DC motor using the L9110 motor driver and Arduino MEGA 2560.
Here's the code

#include <Arduino.h>

const int rightA = A3;
const int rightB = A2;

void setup() {
  Serial.begin(9600);

  pinMode(rightA, OUTPUT);
  pinMode(rightB, OUTPUT);
}

void loop() {
  Serial.println("tick");

  digitalWrite(rightA, HIGH);
  digitalWrite(rightB, LOW);
  Serial.println("waiting for 1s...\n");

  delay(1000);

  Serial.println("stopping");
  digitalWrite(rightA, LOW);
  digitalWrite(rightB, LOW);
  
  Serial.println("waiting for 5s...\n");
  delay(5000);
}

So it should spin the motor for 1s, then wait for 5s and repeat. This only happens once or twice and then Arduino either freezes or restarts and the motor stays on.

Here's the schematic:
I use a separate power supply for the driver board, connected GND of Arduino and the driver, and also have a 100nF capacitor connected. These are the first most obvious issues I found on other forums, so this shouldn't be a problem.
The external power adapter is 5V 1A, and the motor current draw shouldn't exceed 500mA. Yet, it still doesn't work. Could anyone point me in the right direction as to where to look?

I use these motors

The motor power supply is inadequate. The free running current draw for the tank motor is specified as 200 mA, and the start/stall current (briefly drawn every time it starts moving) can be more than 10X that, or 2 Amperes.

A modern MOSFET motor driver would be a much better choice than the very inefficient L9110. Pololu has the best selection.

hmm, so are you saying the problem could be with the motor driver? But how can it affect the Arduino board (being restarted), if they both have their own power supply? :thinking: Just trying to understand what's going on there

There IS a problem with both the motor power supply and the motor driver.

I don't know why that problem should cause the Arduino to restart, though. If you have long, looping wires, radiated electrical noise from the motors and wiring could be a problem.

Post a closeup, focused photo of your setup.

would L298N maybe work better here? I see it supports up to 2A per motor.

are these wires considered to be too long?

No, that ancient dinosaur has an even higher internal voltage drop (up to 4V wasted as heat). Use a modern motor driver.

The wiring is a mess, and the photo shows that your schematic is not correct, as not all the parts are shown. So, no one can guess what is causing the reboots.

haha :joy: do you have a specific driver in mind that would work in this case?
regarding the wiring and the schematic, I know it's a mess, heh. The code that I posted here is what's in Arduino now, I just didn't remove the rest of the sensors from the board, I'll try to remove everything, and only run it with the motors, but I think I'll need a new driver anyway, after what you said.

edit: the reboots only started happening when I started implementing the motors part, other sensors and Bluetooth are working as expected

TB6612FNG and re-write your code for this table...

//***************************************************************
// TB6612FNG PIN STATES                         MOTOR DIRECTIONS
//***************************************************************
//  LDIO  LPWM  RDIO  RPWM  RESULT              LEFT      RIGHT
//  HIGH  rate  LOW   rate  forward             forward   forward
//  LOW   rate  HIGH  rate  reverse             reverse   reverse
//  LOW   rate  LOW   rate  rotate left         reverse   forward
//  HIGH  rate  HIGH  rate  rotate right        forward   reverse
//  LOW   LOW   LOW   rate  skid forward left   stop      forward
//  HIGH  rate  LOW   LOW   skid forward right  forward   stop
//  LOW   LOW   LOW   rate  skid reverse left   reverse   stop
//  HIGH  rate  LOW   LOW   skid reverse right  stop      reverse
//  LOW   LOW   LOW   LOW   stop                stop      stop
//***************************************************************

Thank you!
I'll buy the chip and try again, hopefully this will fix the issues.
If so, I'll post a video of the robot later :grin:

Hi, @joci
Is this your project?

If you disconnect the motors and run the code, does it reset?
Otherwise;
Remove all the other peripherals and just have what you posted in post #1 connected.
NO other gear.

Then run your code.

Do you have a DMM? (Digital MultiMeter)

Tom... :smiley: :+1: :coffee: :australia:

hey guys, I'm back with good news!

I just connected the TB6612FNG driver board and the motors are spinning :tada: I'm using an external power supply but it works now.
And I can confirm that those Arduino restarts were caused by drawing too much current by the motors.

Thanks everyone for your help!

2 Likes