L298N ENA/B PWM Speed Controlling Not Working

Hello!
I am currently using an Arduino R4 Minima board and an L298n Motor Driver.
I tried to use them following this tutorial from the arduino project hub and this one from YouTube.

When I have the jumper wire connecting the ena pin to the other pin (see green circle diagram below), everything works smoothly. However, when I remove the jumper pin and attempt to control the speed of the motor via the ena pin, the motor will not spin at all. I have 2 of these drivers and neither work with the ena/enb pins, and I tried all the pwm ports on my arduino, but to no avail. Thank you!

Current code I am using to attempt to control the motor speed (taken from the arduino project hub article)
int motor1pin1 = 2;
int motor1pin2 = 3;
int motor1ena = 11;

void setup() {
  // put your setup code here, to run once:
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(motor1ena,  OUTPUT); 
}

void loop() {
  // put your main code here, to run repeatedly:

  //Controlling speed (0  = off and 255 = max speed):     
  analogWrite(motor1ena, 100); //ENA  pin
  
  digitalWrite(motor1pin1,  HIGH);
  digitalWrite(motor1pin2, LOW);
  delay(3000);

  digitalWrite(motor1pin1,  LOW);
  digitalWrite(motor1pin2, HIGH);
  delay(3000);
}

Diagram of my circuit

Due to limitations, I wasn't able to post this in the original post, but here is a video (albiet low-quality) of my problem.

Video of my problem

20250215_155618.mp4 - Google Drive

Please extract the essential information and post it here. No way watching tutorials.
Here's some advice: How to get the best out of this forum - Projects / General Guidance - Arduino Forum

To power motors from an Arduino is asking for problem. Get an external psu.

1 Like

  • Never power a load from your Arduino. :scream:
    i.e. only very light loads are allowed.
1 Like

Resolution is ok, but I have some more bad news:

Never use metal objects in powered up electronics. Those pliers can easily short something out.

Besides this I think you're making progress :wink: :upside_down_face:
Curious to hear how it works with an separate psu

2 Likes

Oh my bad about the links... its a shame people try to post malware here.

Lol yeah once I get my step up module, we'll see how it goes... :sweat_smile:

Recieved the voltage conveter, and the ena pin works, kinda...

At first the motor spins just fine, but in 5 seconds it goes to spinning normally to being too weak to spin, whilst both the motor and blue voltage converter make weird noises.

So you power the motor from a separate PSU now? Please make a complete diagram this time.

1 Like

Oh yes my bad.

The first green one boosts the voltage from 1.5v to 5v and the second blue one (which is the one making a clicking noise) boosts the voltage from 5v to 12v, which then powers the L298n.
My arduino is powered by my laptop from a USB C cable.

Please elaborate on the 1.5 part. In the picture the batteries are in series = 6 V

How many batteries, what size?

1 Like

Four double A, 1.5v each.

Oh my gosh I am dumb thank you so much :pray:
So I'm probably overloading that first green voltage converter...
Tomorrow I'll fix the circuit and see what happens

Maybe, but if it haven't released the magic smoke yet it's probably ok.

Best setup would be a 12 V battery, or Lithium batteries to get 3.6 V x 4 and go downhills from that. You could drive the motor without any conversion, and one buck converter for 5 V, smaller losses.

1 Like

Sorry for the delay, I had quite the busy week :sweat_smile:
Anyways though, I soldered 2 4-AA battery packs together to make an 8 AA battery pack, wired that to the L298N, and ran the code.
It does run for a lot longer (15 seconds), and the PWM speed works, but then proceeds to dp the same thing of rapidly deteriorating to spinning weakly to not at all, even though the voltage of the batteries only dropped to 12.2V (although it does seem weird how 8 AA batteries were delivering more than 12V...)

I think your L298N is busted, do you have a spare?

Another thing, why not power your Uno from the batteries to Vin directly?

New batteries can be at a slightly higher V.

1 Like

I figured out that for some reason the L298N wouldn't work if I powered the arduino from it's 5v output, so I used a seperate power supply for said arudino (3 AA batteries with 5v step up)
I was going to try to use my spare L298N, however, when I plugged my 5v power supply to the Arduino 5v pin (mistake #1, should've used the VIN pin), the arduino didn't turn on. I then made a big mistake and connected my laptop to it via USB (mistake #2) and got the rice krispy electric death omen of snap, crackle, and pop....

So I gueas that's the end of that for now..., thank you for all your help though! :folded_hands:
(I might get another one... I never like leaving a project unfinished)

1 Like

No! That sucks, I'm sorry to hear that. What released the magic smoke, whether it was visible or not?

The middle black chip had a little explosion and flame. There is a little hole where it detonated and shot a little flame from

Yikes. One careless move and it's gonski. :confused:

Get back soon, take care now.

1 Like

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