Can't get L298N to power 2 motors with Arduino Uno

Motor_Schematic.png (104915Bytes)

Motor_Schematic.png

I am using an arduino uno and a L298N motor driver board. I have pins IN1, IN2, IN3, IN4 connected to arduino digital pins 2, 3, 4, 5 respectivly. ENA and ENB are connected to pins 9 and 10. The code I am using works because all it is made to do is make the motors go forward. I know it's working because there are four indicator LED's that correspond with the input pins. At the start, all of them light up because I declare them as outputs. After, only pins 1 and 3 light up because I active those in the code to make it go forward. However, only one motor moves. I have tried adjusting all the shorting blocks on the board to no avail. I know the motors work because I applied voltage directly and they worked fine. Is there a problem with my code? I have a 9V connected to the motor board. I know there is about a 2V drop with this chip. That means the motors get 7V, or 3.5V each. The motors are rated at 3-6V each. I ran my code and that one motor worked. I have checked all my wiring and can't seem to figure it out. What I did find out was that the board might be bad. I switched the motors around. Meaning I put the left motor wires in the opposite screwblocks and same for the right. This made the other motor work; making me think my board is partially bad. Do you think it is? Do you think it needs more voltage? If you think the board is bad could you recommend a different one? Regardless, I was still quite happy to see just one motor going as that was the first code I ever wrote on my own. I never learned how to code I just looked at others and read the arduino libraries. It was a nice confidence boost.

I also attached the picture of the schematic in case it is too hard to see. 

 

CODE:

 

 

// This program uses an Arduino Uno and a L298N motor driver board. It will make both motors go forward.

 

int fPinA = 2;    // Forward for motor A (left)

int rPinA = 3;    // Reverse for motor A (Left)

int toggleA = 9;  // Turns motor A on/off

 

int fPinB = 4;    // Forward for motor B (Right)

int rPinB = 5;    // Reverse for motor B (Right)

int toggleB = 10; // Turns motor B on/off

 

 

void setup()

{

   pinMode( fPinA, OUTPUT );   

   pinMode( rPinA, OUTPUT );

   pinMode( toggleA, OUTPUT );

   pinMode( fPinB, OUTPUT );   

   pinMode( rPinB, OUTPUT );  

   pinMode( toggleB, OUTPUT );

}

 

void loop()

{

   digitalWrite( toggleA, HIGH );  // Turns motor A on

   digitalWrite( fPinA, HIGH );    // Makes motor A go forward

   digitalWrite( rPinA, LOW );     // Reverse not used

 

   digitalWrite( toggleB, HIGH );  // Turns motor B on

   digitalWrite( fPinB, HIGH );    // Makes motor B go forward

   digitalWrite( rPinB, LOW );     // Reverse not used

}

Look for cold solder joints

Some of these boards have bad solder joints.  You may have to flux and reheat them or at the very least reheat.

If you ask me the grounds of

If you ask me the grounds of the Arduino and the motor board should be tied together. 

Also the 5v logic voltage is needed on the l298 board. 

Never thought of that

Does this mean the ground from the 9v and the ground from the arduino go together in the same screwblock? Or just forget about the 9v one? Also you said the 5v logic voltage is needed on the board. So does that mean the 5v along with the 9v? Sorry Im relatively new to this.

Does this mean the ground

 

Does this mean the ground from the 9v and the ground from the arduino go together in the same screwblock?

Yes. That’s what I mean. But you can also use the ground pin on the uno. 

 

And about the 5 volt, on the aduino uno board at the power pins section there is an 5v+ output pin. Connect this to the 5v logic port of the l298 board. 

O wait… That l298 board has an build in 5v regulator, I just found out. So only the ground wire is needed then.