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,
[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.
