Hello, I'm building an Arduino based car/tank, and as I'm tinking with the dc motors, I started having problems with the L298N motor driver.
I'm using 2 12V 30 rpm motors, both working without problems if connected directly to a power source, but if connected to the out1 and out2 of the l298n module they do not rotate backwards. The code doesn't seem to be the problem because the same code works for the out3 and out4 with both motors.
I'm using a bit less then 12V, may that be the problem?
Working in forward but not reverse is probably going to be a connection problem. The fact that the other motors, which have completely different connections, work doesn't really really tell you anything.
But please post the full code too because it could also be a small difference in the code that you just haven't spotted.
Steve
This is the code
It makes it run in one direction at high speed, then mid speed, then stop, but it doesn't do anything when the high and low are reversed
#define enA 9
#define in1 6
#define in2 7
int Stop = 0;
void setup() {
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
// Set initial rotation direction
}
void loop() {
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(enA, 250); // Send PWM signal to L298N Enable pin
delay(2000);
analogWrite(enA, 150);
delay(2000);
analogWrite(enA, Stop);
delay(2000);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, 250); // Send PWM signal to L298N Enable pin
delay(2000);
analogWrite(enA, 150);
delay(2000);
analogWrite(enA, Stop);
delay(2000);
}
sadly I do not possess a voltmeter, but that's what I thought too, I will try increasing the power to 12-14V
If connected directly to the battery it goes both ways, so its not a motor problem, if I reverse the connections between the motor and the l298n it goes reverse but not forward
Carefully check the connections to in1 and in2. It's sounds like one of them may not be connected and so the pin is floating. Could be a bad connection or even a wire break inside the insulation. If you're using a breadboard try moving the L298 to a different physical position.
Not having a simple meter that can check these things really does make life more difficult than it needs to be.
Steve
I would like to thank you all, I added a volt meter and I fixed the connection, now it's working perfectly!