0

I'm using a L298N motor driver with an UNO and when I try to run a motor few seconds for forward and few seconds backward, it will only move for a single direction and remain still in the second period. But when I try to run it only for a single direction at a time it is working fine for the both directions. I tried connecting both motor terminals of the motor driver but the problem remains same. This problem only happens when I try to combine the movements for both directions. Here is the piece of code I used for that,

void setup() { pinMode(5,OUTPUT); pinMode(6,OUTPUT); } void loop() { digitalWrite(5,HIGH); digitalWrite(6,LOW); delay(5000); digitalWrite(5,LOW); digitalWrite(6,HIGH); delay(5000); } 

here's the circuit,

L298N diagram

[edit] I have used an external 5v power supply for the motor driver and the +12v and GND pins of the motor driver have directly connected to them. (I have used the +12v terminal for it even I'm using a 5v supply because I searched up about it and some of them advised to do it. Also I tried connecting the motor driver via the 5v terminal but then the output voltage puts lower than the operating voltage of the motor.)

Motor drivers Input3 and Input4 have connected to the UNO's pin5 and pin6.

6
  • 2
    Please, add a schematic of your circuit showing how you wired the grounds and the EN pin. Commented Sep 30 at 13:09
  • @EdgarBonet I have uploaded the schematics. I'm using an external 5v supply to power up the motor driver and the motors. Commented Oct 1 at 5:39
  • The pin names on the motor driver are not readable. Commented Oct 1 at 6:29
  • Did you connect the ground of the motor power supply with the ground of the Arduino? (Please edit your question to clarify, do not use a comment. This is not a forum.) Commented Oct 1 at 6:30
  • @thebusybee edited Commented Oct 2 at 3:10

1 Answer 1

2

Two important connections are missing from your schematic:

  • The ground of the motor's power supply should be connected to Arduino ground

  • the ENB pin of the breakout board should be connected to +5V, either with the supplied jumper, or with the Arduino's +5V

Without these connections, the circuit cannot work reliably.

1
  • This worked. Thank you for pointing out. Commented Oct 3 at 16:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.