L298N not working properly

I am using a arduno mega with l298n and a motor. the l298n is powered with 12V power source and arduino mega is connected to laptop usb. now when I switch on the power supply the motor rotates for a instance like 1 rotation and then stops. when i reset the arduino board it again rotates for a instance and stops. i i keep the reset button pressed the mottor rotates. this is the code i am using.

const int IN1 = 8;
const int IN2 = 9;

void setup() {
  // put your setup code here, to run once:
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  digitalWrite(IN1, HIGH); // Set IN1 HIGH
  digitalWrite(IN2, LOW);  // Set IN2 LOW


}

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

}

Show how your Arduino Mega, L298N, power supply are connected, with a clear picture and a drawing of the connections and pins. Get a close picture of the L298N, too.

2 Likes

  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  digitalWrite(IN1, HIGH); // Set IN1 HIGH
  digitalWrite(IN2, LOW);  // Set IN2 LOW

  • Explain to us what happens in the above code ?

  • Always show us a good schematic of your proposed circuit.
    Show us good images of your ‘actual’ wiring. Give links to components.

@jainish8484
So what is your question?

Can you post an annotated schematic showing exactly how this is wired with links to the hardware devices technical information.

If all your connections are correct, your sketch should be turning RIGHT in a circle, with the left motor (IN1) driving forward (HIGH) and the right motor (IN2) not driven (LOW).

The surge-then-stop is probably a bad connection... is the JUMPER for the VSS/VS inserted?



Here is the link to video of what happens when i switch on the power: https://youtu.be/H7_KWyZZxwg

Check that your programming codess have followed the following Truth Table:

ENA  IN1  IN2      Function
5V   5V   0V       Forward Rotation
5V   0V   5V       Reverse Rotation
5V   PWM  0V       Variable speed at Forward Rotation

What is the 12V supply's current rating?
What is the motor's voltage and current requirements?

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