Error with PWM on arduino nano and Driver: DVR8833


I'm trying to built a line follwer, I used the DVR8833 library and try to program it by myself but it didn't move like I want, with the library if I use driver.motorAStop(); the motor start to work at full capacity, if I tried to assign a value with driver.motorAForward(any value); the motor stops.

If I don't use the library, I can control just one of the motors, the other one goes at full capacity or don't move at all, I change the code so much times, but just the motor A works fine, instead on the library's code the motor B works perfectly.

Here's without library: (ignore the sensor stuff that works perfectly)

int BIN_1 = 12;
int BIN_2 = 8;
int AIN_1 = 6;
int AIN_2 = 9;
int MAX_PWM_VOLTAGE = 240;
unsigned int state=0;
void setup()


void loop()
if((sensorValues[3] < 500) && ((sensorValues[4]) < 500)){
    analogWrite(BIN_2, 50);
    digitalWrite(AIN_2, LOW);
    digitalWrite(BIN_1, HIGH);
    analogWrite(AIN_1, 250);
    analogWrite(BIN_2, 255);
    digitalWrite(AIN_2, LOW);
    digitalWrite(BIN_1, HIGH);
    analogWrite(AIN_1, 0);

And here's with library:

const int inputA1 = 5, inputA2 = 6, inputB1 = 9, inputB2 = 10;

// The speed of the motors:
const int motorSpeed = 128; // Half speed (255 / 2).

void setup() {

  // Attach the motors to the input pins:
  driver.attachMotorA(inputA1, inputA2);
  driver.attachMotorB(inputB1, inputB2);


void loop() {

// Pause the motors for stability:
// driver.motorAStop();
// driver.motorBStop();

Hope someone can help me, and thanks!!

int BIN_1 = 12;
int BIN_2 = 8;
int AIN_1 = 6;
int AIN_2 = 9;

On the Nano Pins 8 and 12 are not pwm outputs. You can only use analogWrite() with pins 3,5,6,9,10,11.

Yep, I took the pins wrong because of this image
But yeah I have to assign as the D# says, thanks for your comment, that helped me to realized.

But look there's no sense, pin 3 is RST, 5 is not pwm. Or... I have to assign them as unisigned char and put: D3, D5.. etc??

Edit: You mean pin 3 is actually D3?and I took it as 6 because of that order, pin 5 is D5... and so on?

Yes, the pwm pins are D3,D5,D6,D9,D10,D11. In the pin out you linked, the printing on the board itself, and the nomenclature on the outside are what's important. The 0-16 and 16-30 relate to the physical description of the board and do not reference the Arduino pin names.