L298N Malfunction?

Hello , i am using an L298N motor to power 2 hobby gear motors. The program has been borrowed from a website to simply test the motors , and i have used several programs to troubleshoot if its a software issue , but it seems to be a hardware issue. If i get one of the digital pins for ENA or ENB and hold a wire from it onto a jumper on ENA or ENB , that sides motor will start spinning , but i am unsure as to if it is possible to either use the motor with the jumpers on and have it still work , or how to get it working without the jumpers.
Image and code included below ;

int motor1pin1 = 2;
int motor1pin2 = 3;

int motor2pin1 = 4;
int motor2pin2 = 5;

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

  //(Optional)
  pinMode(9, OUTPUT); 
  pinMode(10, OUTPUT);
  //(Optional)
}

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

  //Controlling speed (0 = off and 255 = max speed):     
  //(Optional)
  analogWrite(9, 100); //ENA pin
  analogWrite(10, 200); //ENB pin
  //(Optional)
  
  digitalWrite(motor1pin1, HIGH);
  digitalWrite(motor1pin2, LOW);

  digitalWrite(motor2pin1, HIGH);
  digitalWrite(motor2pin2, LOW);
  delay(3000);

  digitalWrite(motor1pin1, LOW);
  digitalWrite(motor1pin2, HIGH);

  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, HIGH);
  delay(3000);
}

The EN-pins are Enabling/disabling the output of the L298N. When disabled, or motors not pulsed, no current will flow.
Read the datasheet of the L298N for how to operate them!
Why the fear of the jumpers?

The removable jumpers (Berg jumpers) on the ENA and ENB pins pull the pins up through (10k?) resistors to the module's Vcc bus so the channels are enabled without needing an external wire. The Arduino's output pins can still pull the pins LOW to DISABLE the channel, no need to remove them. Only reason I see to remove them is if you wanted a coasting stop.

Do you need a common ground between the l298 supply and the Arduino?

1 Like

Yes!

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