DC Motor Rotation Problem

Please Help,

I have l298n motor driver that connects into two DC motors. Motor A rotate forward and backward nicely, but Motor B rotate forward only. My problem is why Motor B can not rotate backward? I check my wirings and codes, then I think they correct. Does my l298n driver is defective? Thanks.

void advance()
{
digitalWrite(pinRB,HIGH);
digitalWrite(pinRF,LOW);
digitalWrite(pinLB,HIGH);
digitalWrite(pinLF,LOW);
analogWrite(enA,255);
analogWrite(enB,255);
}

void backward()
{
digitalWrite(pinRB,LOW);
digitalWrite(pinRF,HIGH);
digitalWrite(pinLB,LOW);
digitalWrite(pinLF,LOW);
analogWrite(enA,255);
analogWrite(enB,255);
}

Looks like maybe you should have:

    digitalWrite(pinLB,LOW); 
    digitalWrite(pinLF,HIGH);

in place of:

    digitalWrite(pinLB,LOW); 
    digitalWrite(pinLF,LOW);

in backward().

Thank you very much sir, for the reply.

I tried to apply the code below,
digitalWrite(pinLB,LOW);
digitalWrite(pinLF,HIGH);

but still motor B does not rotate backward.

I observe the red LED lights in l298n driver, they are properly switching in pattern to the source codes but the motor B does not respond still.

any further suggestion sir. thanks. :slight_smile:

Could you send a picture of your setup, or a wiring diagram? I am currently using one of these motor drivers and have mine working well.

Attached is the wiring diagram.

Sorry for the design of the picture sir.

Swap motors to discern whether the problem is the motor or the driver.

Your wiring seems to all be correct. Make sure also that you have a common ground between your arduino and your motor controller; this just means that you have to connect the two together. Also assuming that you are using one of the prebuilt L298N motor controller boards make sure you still have the jumper right above the power plugs in place.

Follow Artic_Eddie's advice first and see if the issue persists with the motor. If the issue then occurs on the other motor it is either the code or it is controller, if the issue happens on the same motor then it is the motor that is causing the issues.

ok sir, i will do trial and error.

thank you very much for the help sir.