Go Down

Topic: Problem with wierd L298N motor controller (Read 1 time) previous topic - next topic


Hello everyone,

I have ordered this cheap board which looks like this:


Is anyone had to deal with this kind of motor controller and could help me and tell how to connect it to Arduino and how to control speed of motors with PWM signal?

I've tried to connect pins INA, INB with arduino pins for controlling OUTA and OUTB, and PWM signal to ENA pin, above INA, INB but it's not working  :(

Thank you very much for your answers!


Oct 21, 2015, 09:37 pm Last Edit: Oct 21, 2015, 09:39 pm by jremington
Did you connect the Arduino and motor driver grounds together?
Did you supply 5V?
Did you attach motors?
If so, what motors?
What did you use for a motor power supply?
Did you program the Arduino?
If so, what program? (Post using code tags).
Show a diagram of all your wiring.


Thanks for your replay!

My diagram looks like this: (second motor was not wired):

Of course, I removed the jumper from EAN and +5V and connect it with PWM port 6.

My code:

Code: [Select]

// connect motor controller pins to Arduino digital pins
// motor one
int enA = 6;
int inA = 2;
int inB = 3;

// motor two
int enB = 5;
int inC = 7;
int inD = 6;
void setup()
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(inA, OUTPUT);
  pinMode(inB, OUTPUT);

void loop()
  digitalWrite(inA, LOW);
  digitalWrite(inB, HIGH); 

  // accelerate from zero to maximum speed
  for (int i = 0; i < 256; i++)
    analogWrite(enA, i);
  //stop engine
  analogWrite(enA, 0);

After programming arduino motor don't run. I can't hear any sound from motor or motor control board. What I'm doing wrong?


Oct 22, 2015, 06:04 am Last Edit: Oct 22, 2015, 06:14 am by DuaneDegn
Did you connect the Arduino and motor driver grounds together?
I second jremington's question. Your diagram doesn't show the how the Arduino is powered but if it's powered from a separate supply, the ground lines need to be connected together.

It looks like the board has a push button. It probably needs to be in the down position to work.

If you're feeling brave, you might want to (eventually) power the Arduino from the 5V regulator on the L298N board. Don't try this yet, but after you get things working, you might be able to run your motors and Arduino from the same battery.

What kind of motors are you using? Are you really using a 9V battery (those are awful for powering motors)?

If things still aren't working after connecting grounds, it would probably be a good idea to post a photo of your setup.

Edit: It appears you understand how the L298N is supposed to work, but it still might help to take a look at the video I made on the topic. I used a different microcontroller in the video but the principles still apply. The PCB I used is also different but there are enough similarities to your board to likely make the video applicable to this application.

One thing I generally do when I have a new h-bridge which I'm not sure about is to try to control the h-bridge's logic directly by using ground and 5V connected to the various logic pins. This eliminates any possible programming errors so I can make sure the logic pins actually behave as I expect.


I forgot about showing how arudino is powered. It has power from USB now (for testing motors).

I'm using standard motor with wheel ( 3 - 5V, 50-83 rpm) and also 9V battery. What's wrong with that kind of battery?


To get the control signal from the UNO to the motor controller, you need your signal connections 
PLUS the gnd of the arduino and gnd of the motor controller to be connected together as well.

Please read posts   #1 and #3.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....


OK, thanks for your replies!
I'll try your advices soon and will share with results!


I'm using standard motor with wheel ( 3 - 5V, 50-83 rpm) and also 9V battery. What's wrong with that kind of battery?
There might be "standard" motors in some applications but there certainly aren't standard motors in robotics (maybe FIRST or some other regulated event). It's always a good idea to provide links to items you're asking about though it's not a big deal in this case.

The little rectangular 9V batteries are very useful for low current devices like smoke detectors or multimeters. They're really bad batteries for powering motors and servos. They can't provide the current required by motors and servos, at least not for long.

It's a very common beginner problem to underestimate the amount of power one needs in a robot. A L298N can be powered with four NiMH AA cells but it's technically out of specs (it might not work at all with 5V logic). You will be much better off with five or six NiMH AA cells or a decent LiPo pack of at least two cells.

Rechargeable batteries can generally provide higher currents than alkaline cells.

The 9V battery may work well enough to test your setup but it's not likely to last long.

I've been active in other robotics forums for many years, I've seen lots of problems caused by people using 9V batteries. They just can't produce the current demanded by many robotic tasks such as driving motors and hobby servos.

I don't think the 9V battery is your main problem and it might work well enough for testing. I think the main problem is the lack of a shared ground connection.

Go Up