Not able to control DC motor speed with l298N & pwm pins I am using arduino uno to control dc motor speed with L298N. But the problem is that the motor is only going at max speed. PWM pin doesn't work for some reason.
I heard many people had some problem but haven't found the solution yet.

code:-

#include &lt;L298N.h&gt;

#define ENA 9
#define IN1 8
#define IN2 7

L298N motor(ENA, IN1, IN2);

void setup() {
// Setup pin mode

//used for display information
  Serial.begin(9600);

}

void loop() {
//Drive Motor Forward
  motor.setSpeed(10);
  motor.forward();
  delay(500);
  motor.setSpeed(100);
  motor.forward();
  delay(500);
  motor.setSpeed(255);
  motor.forward();
  delay(500);

}


I only see the motor move at full speed every time. I connected 5V of Arduino to +12V pin of motor driver and Arduino is powered with my laptop USB. 

I am using 4.5V toy dc motor for test - DC motor

What could be wrong here?
Try to use this code, without the library, and be shure to connect every pin to the correct arduino output! If everything is ok it should work! Check a tutorial here 

int IN3 = 5;    
int IN4 = 4;     
int ENB = 3;    
void setup()
{
 pinMode (ENB, OUTPUT); 
 pinMode (IN3, OUTPUT);
 pinMode (IN4, OUTPUT);
}
void loop()
{

  digitalWrite (IN3, HIGH);
  digitalWrite (IN4, LOW);   
  analogWrite(ENB,55);
  delay(2000);
  analogWrite(ENB,105);
  delay(2000);
  analogWrite(ENB,255);
  delay(2000);
  analogWrite(ENB,0);
  delay(5000);
}