DC motor not running(L298N)

Hello everyone,
I am using arduino uno with a l298N motor driver.I connected 2 DC motors with it.I used 4 (1.5V AA batteries)+3.7 Li-ion battery in series with it ,making it a 9.7V battery.The system worked fine when there the batteries were used to drive the motors only.When i used the arduino and uploaded my code(arduino taking power from pc,motor taking power from batteries) the motor actually worked according to my code.But whenever i disconnected my pc from arduino and took power from the batteries to power the arduino also, the motors worked for a few seconds and then stopped working.It was during that time the programable LED of arduino uno kept on blinking for some unknown reason.Can anyone help me??I can also provide the video of what happened with system if anyone wants in order to solve my problem.My code-

int motor1_in1=5;

int motor1_in2=4;

int motor2_in1=8;

int motor2_in2=9;

int motor1_ENA=3;

int motor2_ENB=10;

void setup() {

pinMode(5,OUTPUT);

pinMode(4,OUTPUT);

pinMode(8,OUTPUT);

pinMode(9,OUTPUT);

pinMode(3,OUTPUT);

pinMode(10,OUTPUT);

}

void loop() {

//Forward:

analogWrite(motor1_ENA,255);

analogWrite(motor2_ENB,255);

digitalWrite(5,1);

digitalWrite(4,0);

digitalWrite(8,1);

digitalWrite(9,0);

delay(6000);

//Backward:

analogWrite(motor1_ENA,180);

analogWrite(motor2_ENB,180);

digitalWrite(5,0);

digitalWrite(4,1);

digitalWrite(8,0);

digitalWrite(9,1);

delay(3000);

//Right:

analogWrite(motor1_ENA,180);

analogWrite(motor2_ENB,180);

digitalWrite(5,0);

digitalWrite(4,0);

digitalWrite(8,1);

digitalWrite(9,0);

delay(4000);

//left:

analogWrite(motor1_ENA,180);

analogWrite(motor2_ENB,180);

digitalWrite(5,1);

digitalWrite(4,0);

digitalWrite(8,0);

digitalWrite(9,0);

delay(4000);

//Stop:

digitalWrite(5,0);

digitalWrite(4,0);

digitalWrite(8,0);

digitalWrite(9,0);

delay(4000);

}


Make and post schematics of the troubeling setup. Words telling "connect" ..... tells nothing. By the way, connecting different batteries like that will spell diaster for the li-ion battery quite soon.

MOTORS:
DC yellow motor1-out1,out2 pins(on L298N)

DC yellow motor2-out3,out4 pins(on L298N)

ON BREADBOARD:
Driver +12V pin-took power from the battery combination(9.7V) +added arduino Vin pin to it

Driver GND pin-connected to bread board+connected arduino uno GND pin to it as well

Driver +5V pin-Didn't use it,left as it is

ARDUINO CONNECTION:
ENA-PWM No.3 pin on arduino
ENB-PWM No.10 pin on arduino
In1-no.5 pin on arduino
In2-no.4 pin on arduino
In3-no.8 pin on arduino
In4-no.9 pin on arduino

Used M-M,M-F,F-F jumper wires for all the connections

Please post a schematic. Written descriptions are always more ambiguous than a drawing. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.

If you want to try CAD for a schematic, see How to make a schematic to post.

1 Like

The reason should not be a mystery. IT blinks because your Arduino is rebooting over and over,

1 Like

Your pictures are useless, there is way to much clutter in them. When the Li battery becomes a fire ball take a picture of that. Save all of us a lot of time and post a schematic. Also post links to "Technical information" on the hardware items. Your choice of parts is far from the best. If you have a trash can that is the perfect place for the L298N, get a bridge with MOSFET outputs. Use your multimeter and measure the voltage at the battery then at the motor you should then understand what is happening.

But why is the arduino rebooting in the middle of running the code?Its not executing the the full code yet executes some part and after some time doesn't even do that as well.Can you tell me why?

First time posting in the forum,didn't know all the rules of posting .Well i get that people are of different attitudes.By the way thanks for being brutally honest.About the clutter and trash can part-I am a new learner

Certainly. Easy. The Arduino power, voltage or current, is being vastly reduced or completely turned off for an instant. When you have drawn a schematic or even a block diagram of how you have all this project wired together, perhaps the source of the problem will be found.

1 Like


Let me know if this helps

If even one of your non-rechargable cells has a high internal resistance, the Arduino voltage will drop below the minimum necessary to operate. Check the total voltage of your battery string while trying to run the motors.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.