L298 motor driver spinning motor in only one direction

Hi, I working on one of my project using ESP32 and L298 motor driver. L298 was working fine till yesterday but today it is spinning in only one way with ESP32 as a main board. I'm powering L298 driver with 12v, driver ground is grounded with ESP32 ground.

int motor1Pin1 = 13; 
int motor1Pin2 = 14; 



void setup() {
  // sets the pins as outputs:
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);

  

  Serial.begin(115200);

  // testing
  Serial.print("Testing DC Motor...");
}

void loop() {
  // Move the DC motor forward at maximum speed
  Serial.println("Moving Forward");
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, HIGH); 
  delay(2000);

  // Stop the DC motor
  Serial.println("Motor stopped");
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, LOW);
  delay(1000);

  // Move DC motor backwards at maximum speed
  Serial.println("Moving Backwards");
  digitalWrite(motor1Pin1, HIGH);
  digitalWrite(motor1Pin2, LOW); 
  delay(2000);

  // Stop the DC motor
  Serial.println("Motor stopped");
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, LOW);
  delay(1000);

  
}

If you have a 5V Arduino, see if the driver and sketch works with it.

Can you share a picture?
If you use a breadboard, a loose contact might be your problem.

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