DC Motor Control with DRV8801

Hi, my aim is to just control the direction and speed of the Micro-Metal Gearmotor with this motor driver DRV8801.

For now my code is

int PWM1=  2;
int DIR1= 22;
int Brake1= 28;

void setup() {

  pinMode(PWM1, OUTPUT);
  pinMode(DIR1, OUTPUT);
  pinMode(Brake1,OUTPUT);
  digitalWrite(DIR1, LOW);
}

void loop() {
analogWrite(PWM1, 200);
delay(2000);
digitalWrite(DIR1, HIGH);
analogWrite(PWM1, 50);
}

But the motor is neither changing direction nor speed. What am I doing wrong?

int PWM1=  2;
analogWrite(PWM1, 200);

What Arduino board are you using? An Uno (or equivalent) has PWM on pins 3,5,6,9,10,11. Not pin 2.

groundFungus:

int PWM1=  2;

analogWrite(PWM1, 200);




What Arduino board are you using? An Uno (or equivalent) has PWM on pins 3,5,6,9,10,11. Not pin 2.

I'm using the mega 2560 R3

Has been solved, the solder was cold and wasn't connecting the DIR properly.