Using a L298N Driver and Sparkfun RedBoard to control a 12V DC Motor

Hi,

I am working on a project where I need to control the speed of a DC Motor. I am currently using a 12V DC Motor, a L298N Motor Driver and a Sparkfun RedBoard. Below I have included the code I am using (I am just trying to see if I can have control over direction and speed) as well as images of my wiring. I am using a power supply with the shown voltage, which I assumed should work fine as it is below 12. My main problem is that when I have everything wired up as shown and I upload the code, nothing happens. My motor does not spin or hum and there seems to be no change at all. I have tested all the wires and they are all running a current fine. I have also looked online and at other posts and it seems the most common error is not connecting the L298N and Arduino Ground, but I have done that. I am very new to Arduino and electronics, so I am hoping my error is obvious to someone. Thanks in advance for any help!

 int enA = 9;
  int in1 = 8;
  int in2 = 7;

void setup() {
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
}

void loop() {
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enA, 200);
  delay(5000);
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  analogWrite(enA, 200);
  delay(2500);
}

I had trouble posting the images due to size, here is a link to them on imgur:

You could always scale down the images. 640x480 is plenty for most browser images. Then post them here. See this Simple Image Guide

However a photo of a pencil drawing showing how you have everything connected would be a lot more useful than the photos of your hardware.

Can we assume that the motor works if you connect it directly to the power supply?

Have you any means to know if the L298 is broken?

...R

The motor does work if connected to the power supply. I am not sure how I could test the L298. Here is a drawing of the wiring, it is pretty rudimentary and based off of a tutorial, which is why I am having trouble solving my problem. Thank you for your response.

20180524_150016.jpg

I had hoped you would make your drawing visible so I would not have to do it

b17ea8f9d096ed63e91e1fbecce0b508cbf614e7.jpg

And it would be nice if I didn't have to turn my laptop on its side to read it !

...R

I don't see anything wrong with your program or your connections which suggests that the L298 is faulty.

Have you tried both drivers on the L298?

...R

My apologies in regards to the image, I'm new to this sort of stuff. Yes, both connections on the L298 fail.

BigALig:
My apologies in regards to the image, I'm new to this sort of stuff. Yes, both connections on the L298 fail.

I think if it was my project I would get another L298.

Even better would be to get a more modern driver that uses MOSFETs and has a lower voltage drop. The Pololu website has lots of examples and there are many similar products available from other suppliers.

...R

Test that L298 board on it's own, without Arduino.

Put both EN jumpers on.
Connect IN1 to module ground.
And IN2 to module 5volt.
If the motor runs,
Connect IN1 to module 5volt.
And IN2 to module ground.
The motor should run in the opposite direction.

Also test the other half of the chip.
Leo..

Did have another look at the pictures from post#1,
It seems OP has removed the 5volt jumper.
If so, then the logic part of the motor chip won't be powered.

Put that jumper back again, assuming your motor supply is <=12volt.
Or... give the motor driver 5volt power by connecting 5volt from the Arduino to the 5volt terminal of the driver.
Leo..

The motor is working now thanks for all of the help. The L298 came without the jumper so I never realized that it wasn't on anymore. When I connected the Arduino's 5V to the L298 it ran.