L298N board not equal voltage at both output

Hi All,

I am new to aurdino. i was trying to control two 3v-12v DC geared motor using L298N board using PWM signals from aurdino UNO.

ISSUE:

Noticing that motor 1 output (OUT1 and OUT2) gives out 3v to 12v as output voltage when checked with multi meter.

But 2nd output (out3 and out4) gives out starting from 11v. when i supply less than 11v say 3v,6v,10v only output 1 works.

when i give full voltage of 12v then output 1 and 2 both work both supply 11.1v (checked with MULTIMETER).

because of this, i am not able to control the speed of Motor 2.

do let me know what i am doing wrong.

SEtup:

3v-12v 200RPM geared DC motors with 5kg torque
12v 4.5amp power supply.
separate 6v power to L298N board
aurdino uno connected and powered by USB.

Do let me know on why the OUTPUT 2 only works when full 12v is supplied to it. unlike OUTPUT 1 when starts working from 3v.

Code:

//Keyboard Controls:
//
// 1 -Motor 1 Left
// 2 -Motor 1 Stop
// 3 -Motor 1 Right
//
// 4 -Motor 2 Left
// 5 -Motor 2 Stop
// 6 -Motor 2 Right

// Declare L298N Dual H-Bridge Motor Controller directly since there is not a library to load.

// Motor 1
int dir1PinA = 3;
int dir2PinA = 4;
int speedPinA = 8; // Needs to be a PWM pin to be able to control motor speed

// Motor 2
int dir1PinB = 5;
int dir2PinB = 6;
int speedPinB = 9; // Needs to be a PWM pin to be able to control motor speed

void setup() {  // Setup runs once per reset

  //Define L298N Dual H-Bridge Motor Controller Pins

  pinMode(dir1PinA,OUTPUT);
  pinMode(dir2PinA,OUTPUT);
  pinMode(speedPinA,OUTPUT);
  pinMode(dir1PinB,OUTPUT);
  pinMode(dir2PinB,OUTPUT);
  pinMode(speedPinB,OUTPUT);
Serial.begin(9600); // open the serial
   delay(1000); //wait a while to let the user the time to open the monitor
   Serial.println(F("Ready")); //I'm ready

}
   int FCount = 0;
   int RCount = 0;
void loop() {
  //delay(1000);

  // Initialize the Serial interface:
   // Serial.println("TEST");
  if (Serial.available() > 0) 
  {
    Serial.println("YES IAM WORKING");
    int inByte = Serial.read();
    
    //int FCount = 0; // Local variable
    Serial.println(inByte);
    if (inByte == 49)
    {
      int ForwardSpeed = FCount;   
      Serial.println("FORWARD"); //I'm ready
         //delay (200);


      digitalWrite(dir1PinA, LOW);
      digitalWrite(dir2PinA, HIGH);
      digitalWrite(dir1PinB, HIGH);
      digitalWrite(dir2PinB, LOW);
               analogWrite(speedPinB, ForwardSpeed);
               analogWrite(speedPinA, ForwardSpeed);

      if (ForwardSpeed > 255)
      {
      analogWrite(speedPinA, 255);//Sets speed variable via PWM 
      analogWrite(speedPinB, 255);
      }
      else
      {
      analogWrite(speedPinB, ForwardSpeed);
      analogWrite(speedPinA, ForwardSpeed);//Sets speed variable via PWM 

      }
      //Sets speed variable via PWM 
FCount = ForwardSpeed + 50;
RCount = 0;
    }
    else if (inByte == 50)
    {
         Serial.println("STOP"); //I'm ready
         delay(200);
         analogWrite(speedPinA, 0);
      //digitalWrite(dir1PinA, LOW);
      //digitalWrite(dir2PinA, HIGH);
      analogWrite(speedPinB, 0);
      FCount = 0;
      RCount = 0;
      //delay(50);
      //digitalWrite(dir1PinB, HIGH);
      //digitalWrite(dir2PinB, LOW);
      
    }
    else if (inByte == 51)
    {
       Serial.println("REVERSE"); //I'm ready
      delay (200);
      int ReverseSpeed = RCount;  
      analogWrite(speedPinA, ReverseSpeed);
      //digitalWrite(dir1PinA, LOW);
      //digitalWrite(dir2PinA, HIGH);
      analogWrite(speedPinB, ReverseSpeed);
      //delay(2000);
      digitalWrite(dir1PinA, HIGH);
      digitalWrite(dir2PinA, LOW);
      digitalWrite(dir1PinB, LOW);
      digitalWrite(dir2PinB, HIGH);
      if (ReverseSpeed > 255)
      {
              analogWrite(speedPinA, 255);
      analogWrite(speedPinB, 255);
      }
      else
      {
      analogWrite(speedPinA, ReverseSpeed);
      analogWrite(speedPinB, ReverseSpeed);
      }

      RCount = ReverseSpeed + 50;
      FCount = 0;
    }
    
   /* switch (inByte) {

      //______________Motor 1______________

    case '1': // Motor 1&2 Forward
    analogWrite(speedPinA, 0);
      //digitalWrite(dir1PinA, LOW);
      //digitalWrite(dir2PinA, HIGH);
      analogWrite(speedPinB, 0);
    //  delay(2000);
      analogWrite(speedPinA, 255);//Sets speed variable via PWM 
      digitalWrite(dir1PinA, LOW);
      digitalWrite(dir2PinA, HIGH);
      analogWrite(speedPinB, 255);//Sets speed variable via PWM 
      digitalWrite(dir1PinB, HIGH);
      digitalWrite(dir2PinB, LOW);
      //delay(5000);
      Serial.println("Motor 1 Forward"); // Prints out “Motor 1 Forward” on the serial monitor
      Serial.println("   "); // Creates a blank line printed on the serial monitor
      break;

    case '2': // Motor 1&2 Stop (Freespin)
      analogWrite(speedPinA, 0);
      //digitalWrite(dir1PinA, LOW);
      //digitalWrite(dir2PinA, HIGH);
      analogWrite(speedPinB, 0);
      //delay(50);
      //digitalWrite(dir1PinB, HIGH);
      //digitalWrite(dir2PinB, LOW);
      Serial.println("Motor 1&2 Stop");
      Serial.println("   ");
      break;

    case '3': // Motor 1&2 Reverse
        analogWrite(speedPinA, 0);
      //digitalWrite(dir1PinA, LOW);
      //digitalWrite(dir2PinA, HIGH);
      analogWrite(speedPinB, 0);
      //delay(2000);
      analogWrite(speedPinA, 255);
      digitalWrite(dir1PinA, HIGH);
      digitalWrite(dir2PinA, LOW);
      analogWrite(speedPinB, 255);
      digitalWrite(dir1PinB, LOW);
      digitalWrite(dir2PinB, HIGH);
      Serial.println("Motor 1&2 Reverse");
      Serial.println("   ");
      break;

/*
      //______________Motor 2______________

    case '4': // Motor 2 Forward
      analogWrite(speedPinB, 255);
      digitalWrite(dir1PinB, LOW);
      digitalWrite(dir2PinB, HIGH);
      Serial.println("Motor 2 Forward");
      Serial.println("   ");
      break;

    case '5': // Motor 1 Stop (Freespin)
      analogWrite(speedPinB, 0);
      digitalWrite(dir1PinB, LOW);
      digitalWrite(dir2PinB, HIGH);
      Serial.println("Motor 2 Stop");
      Serial.println("   ");
      break;

    case '6': // Motor 2 Reverse
      analogWrite(speedPinB, 255);
      digitalWrite(dir1PinB, HIGH);
      digitalWrite(dir2PinB, LOW);
      Serial.println("Motor 2 Reverse");
      Serial.println("   ");
      break;

    default:
      // turn all the connections off if an unmapped key is pressed:
      for (int thisPin = 2; thisPin < 11; thisPin++) {
        digitalWrite(thisPin, LOW);
      }
    }*/
  }
  
}

Regards,
Senthilprakash

pin 8 is not capable of outputting a PWM signal. Try swapping pin 8 for 3, 5, 6, 10, or 11.

when i give full voltage of 12v ..

Not sure what you are trying to do, but- to be clear you should never see more than 5volts out of an arduino ( or directly into the chip for that matter). you also should not be trying to control Vin voltage to the L298n, just a straight connection to the power source. The inputs on the L298 are logic level so 5v works just fine.