Unable to control DC motor via PWM using L298n module

I'm trying to manipulate a single DC motor (238-9759) using an H-bridge (L298n). I've basically copied the schematics of the multiple tutorials I've read and watched, shown on the image. The polarity of the voltage is controlled via digital pins 2 and 3, and the PWM signal via pin 9. The H-bridge is powered by the 5V output of the Arduino.

The problem is that the tutorials tell me to control the power of the motor (by PWM) by connecting pin 9 of the Arduino to the ENA pin of the L298n. This involves taking off a cap that connects the ENA pin and the 5V pin behind it. Somehow, when I take it off, the motor stops running, and nothing works until I put the cap back off, in which I become unable to control the power of the motor.

It is strange because I am using the exact code and schematic that the tutorials suggest I do.

I would greatly appreciate some help. Thanks!

Code:

int motor1pin1 = 2;
int motor1pin2 = 3;
int ENA = 9;

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

void loop() {
  // put your main code here, to run repeatedly:   
  digitalWrite(motor1pin1, LOW);
  digitalWrite(motor1pin2, HIGH);

  // The code below is never portrayed--the motor stays spinning as though the pin output is 255,
  // that is, as long as the cap is connected
  analogWrite(9,255);
  delay(1000);
  analogWrite(9,200);
  delay(1000);
  analogWrite(9,150);
  delay(1000);
  analogWrite(9,100);
  delay(1000);
  analogWrite(9,50);
  delay(1000);
  analogWrite(9,0);
  delay(1000);
}

The Arduino is not a power supply, and cannot be used to power any motors or servos. You would be wise to ignore any tutorials that suggest otherwise.

Use a separate motor power supply, capable of providing the stall current for the motor, and connect the grounds. The motor power supply needs to be 8V or higher for the ancient, inefficient L298, and about half of the power is typically lost as heat in the L298 itself.

That motor needs roughly 6-12V and up to 3A. Trying drive it via a motor controller that will drop at least 3V of the input voltage and can handle only 1A max powered from a 5V 0.2A pin on the Arduino is never going to work. Those components are just not compatible.

Steve

Sounds like your pin 9 may be fried - can you test it with a resistor+LED? If the enable
pin works when connected to 5V but doesn't via pin 9, then I'd suspect pin 9 or the wire
connecting it to pin 9.

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