Driver L298N not working

Hello, I have a problem about L298N. RED LED on L298N is show but 2dc motors connected to the motor driver don’t seem move : (

I’ve already attached the images (how everything connected) to my post or you can click here to see >Imgur: The magic of the Internet<

my connect on board:
enA = 10
in1= 9
in2=8
enB=5
in3=6
in4=7

and this is my code :
// Motor A
int enA = 10;
int in1 = 9;
int in2 = 8;
// Motor B
int enB = 5;
int in3 = 6;
int in4 = 7;

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

pinMode(enA,OUTPUT);

pinMode(in1,OUTPUT);

pinMode(in2,OUTPUT);

pinMode(enB,OUTPUT);

pinMode(in3,OUTPUT);

pinMode(in4,OUTPUT);
}

void loop()
{
// Motor A
analogWrite(enA, 255);

digitalWrite(in1, LOW);

digitalWrite(in2, HIGH);
// Motor B
analogWrite(enB, 255);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}

Is the power to the motor is too low?
THANK YOU : )

It is much easier to help if you attach the images to your Post. See this Image Guide

Is any of your images a wiring schematic? if not please make a pencil drawing showing how you have everything connected and post a photo of the drawing.

...R

Thank you for your suggestion R :slight_smile:

Is the power to the motor is too low?

How could we possibly know?

You haven't provided any useful information, like the motor voltage and current requirements, the battery type and voltage.

Please read and follow the directions in the "How to use this forum" post. Use code tags when posting code.

It seems you have the 5volt supply output from the motor driver connected to V-in of the Mega.

V-in is the input of the onboard 5volt regulator of the Mega. The V-in pin needs at least 6.5volt for the regulator to make a stable 5volt for the MCU.

If you have a reliable 5volt from the motor driver, connect it to the 5volt pin of the Mega, not to V-in.

But then again, Fritzing pictures are rarely an accurate representation of the actual build. Leo..

Image from Reply #2 so we don’t have to download it. See this Image Guide

f688d7f468c1488686427fad94a6ecb2930360c9.jpg

…R

What is connected to Pin 5 of the Mega?

A pencil drawing with clearly labeled connections would be much easier to interpret - even if you are a poor artist.

...R

Firstly don't try to power an Arduino from a motor supply, its fraught with issues.

Power the Arduino over USB or similar, power the motor supply to the 298 from your battery pack.

The logic supply to the 298 can be the 5V of your Arduino, but then never power the Arduino without the motor supply present or you'll pull large current from the Arduino internally in the L298, which is bad. (There's an internal path for current that is not intended to be used like this - power up motor supply first, then logic supply, power down in reverse sequence).

Measure the supply voltages, make sure they are correct. Try with one motor first, check both channels of the L298. Measure the current taken, make sure you're not overloading the L298.

Never power anything up without double-checking all connections - this is a common beginners error - you need to methodically check everything because a careless error can easily lead to problems or damaged components, which is very annoying, but avoidable if you are careful.

If you have access to a bench supply with adjustable current limit, this is great, it means you can test a circuit with the current limited, often protecting against damage if something is wrong.