l298n motor driver board

Hi
Can any body help me with my l298n motor driver board
I have tried alot of things but the motors won’t run. The LED of the board is turning on .

Can you provide a circuit diagram, containing all used components, including the motor power source? Your power source must match the motor requirements (voltage and current), an Arduino can not normally power a motor.

I attached a photo shows how I connected every thing.

And that’s the code that I am running

// connect motor controller pins to Arduino digital pins
// motor one
int enA = 10;
int in1 = 9;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
void setup()
{
// set all the motor control pins to outputs
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void demoOne()
{
// this function will run the motors in both directions at a fixed speed
// turn on motor A
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
// set speed to 200 out of possible range 0~255
analogWrite(enA, 200);
// turn on motor B
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
// set speed to 200 out of possible range 0~255
analogWrite(enB, 200);
delay(2000);
// now change motor directions
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(2000);
// now turn off motors
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
void demoTwo()
{
// this function will run the motors across the range of possible speeds
// note that maximum speed is determined by the motor itself and the operating voltage
// the PWM values sent by analogWrite() are fractions of the maximum speed possible
// by your hardware
// turn on motors
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
// accelerate from zero to maximum speed
for (int i = 0; i < 256; i++)
{
analogWrite(enA, i);
analogWrite(enB, i);
delay(20);
}
// decelerate from maximum speed to zero
for (int i = 255; i >= 0; --i)
{
analogWrite(enA, i);
analogWrite(enB, i);
delay(20);
}
// now turn off motors
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
void loop()
{
demoOne();
delay(1000);
demoTwo();
delay(1000);
}

I connected the Arduino and the l298 to 9v battery

Such batteries are not very useful with motors, get some more powerful supply. What is the measured battery voltage, when you try to run your motors?

I also suspect that you failed to connect the power to the motor driver properly. The module needs 5V for the logic, which can be obtained from the Arduino, and an additional motor supply voltage. Please try to make a circuit diagram, photos are not very helpful in finding wiring mistakes.

The L298 drops at least 2V so the best you'll get at the motor is 7V. But when the motors ask for significant current like they will do at startup, that drop can be about 5V if my memory serves me.

That leaves you with less than 5V....

That driver is better with higher voltage motors, where the missing 2-5V is relatively smaller.

So can't I use these motors with this board ??
But I see people in youtube use these motors with this board , for that I think that the board may be damaged.
Or what do you suggest to use as a power supply for arduino and l298 board ?

YousefAouf:
So can't I use these motors with this board ??

Nobody said that: you just don't have enough voltage and also as mentioned those 9V batteries are crap, they don't give much current and the little current they do give, doesn't last.

Rather try a pack of 6x AAs, that will give better current although the 9V they give will be reduced by the L298.

Ok if I powerd the l298 with 6×AA battery's
how to power the arduino ?

Also the other guy said

DrDiettrich:
The module needs 5V for the logic, which can be obtained from the Arduino,

how to connect that.

You haven't said what the board part number is although you linked to a pic- have you read its datasheet?

Looks to me like there's a 5V input on the left. But you'll need to find out what that 5V source jumper is on the bottom right of the pic.

Hi,
Try this code

http://www.geeetech.com/wiki/index.php/L298N_Motor_Driver_Board

Tom.... :slight_smile:

manor_royal:
You haven't said what the board part number is

Where is the board part number, I will put a photo for the board in the attachment.

YousefAouf:
Where is the board part number,

Beats me.

But Tom George found you the right info for you anyway.

Read that page he linked: the 3rd, 4th and 5th bullets under Hardware Diagram answer your questions. With the jumper on, the 298 logic 5V is supplied via a regulator from Vms. With it off, the logic gets 5V from what you supply at the 5V terminal at the left. That could be from Arduino 5V, or any reliable 5V of your choice.

Aha
But where i should suply the 5v
In the terminal behind VMS or in the pin behind ENB

Take your ohm meter and check to see if those 2 5V pins are connected to each other. Or, put 5V on one and see if the other measures 5V too. I suspect they're electrically the same point. Probably just for your convenience: one a header pin and one a screw terminal so you have some flexibility in connection.

But the pic you just posted is not the same board as the one you posted in the first post. The first one doesn't have 5V next to ENB, and doesn't say "Keyes" on it.

Just because boards use the same underlying chip, doesn't mean they work exactly the same once a manufacturer surrounds it with other electronics.

Make up your mind which product you have, and go to the manufacturer's site and read the instructions.

The last one is the one that I have

YousefAouf:
The last one is the one that I have

So I have to wonder why you posted a different one almost a full day ago (and for which another member hunted down a page with all the answers).

But anyway, it says "Keyes L298" and "Rev02" on it: go see what Keyes has to say about hooking it up.

This guy used Vms for your Keyes board logic, with the jumper on.

So if you want to use a separate 5V the implication is to take the jumper off, like it is in your last photo. But as I said, it’s easy to see if the 5V next to Vms and the 5V next to ENB are electrically connected.

(Easy if you have a meter…)

Finally :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:
It worked
I have connected the ground and 5V behind ENB in l298 to arduino
And it worked
Thank You all
Yessssssss
After alot of time it worked