Hi everyone, have tried to solve this issue for hours but still have not had luck. Trying to run two DC motors with a L298N motor driver, one 9V battery connected to the L298N and another 9V battery powering the Arduino. Here is some pictures with the code listed below.
9 V batteries are for smoke alarms and are totally unsuitable for motors. You should use a DC power brick capable of supplying 9-12V at 1 or more Amperes instead.
Note that the ancient L298 driver is extremely inefficient, very limited in current handling capability and wastes a large amount of power as heat. You are much better off with a modern motor driver like this one.
Note that the motor driver you choose must be able to handle the stall current of the motor. Either find that on the manufacturer's web page or product data sheet for your motor, or measure the winding resistance with a multimeter. The stall current is the motor voltage divided by the winding resistance (I = V/R).
Finally, did you connect the motor driver ground and the Arduino ground?
Thanks for your help, didnt know that we could not use a 9V battery to power the motor driver. Is it necessary to connect the motor driver ground and the Arduino ground? Our Arduino has a seperate power source so I did not think it mattered.
jremington:
Always necessary to connect the grounds.
The 9V battery might be able to spin one motor for a couple of minutes before dying. But don't count on it!
Like jreminghton said, i guess is the lack of ground between the arduino and the l298, because on the images you posted i cant see any wire connecting the 2 grounds
dulk:
Thanks for your help, didnt know that we could not use a 9V battery to power the motor driver. Is it necessary to connect the motor driver ground and the Arduino ground? Our Arduino has a seperate power source so I did not think it mattered.
If the arduino needs to apply a signal of say 5 volt DC to a particular input port of the motor driver, then that 5 volt DC will certainly be relative to the arduino's ground.
So if the local 'ground' of the motor driver is at some 'other' voltage that is not the same as the arduino's ground voltage ........ then you can think about whether that matters or not. Also, a circuital loop is required to complete a circuit. So if the local 'gnd' of the arduino is not connected to the local 'gnd' of the motor driver, then connecting arduino 5V output (relative to arduino gnd) to the motor driver isn't going to do much (or anything).