Arduino Forum

Using Arduino => Motors, Mechanics, and Power => Topic started by: JazzyJ on Apr 17, 2019, 01:56 pm

Title: DC Motor Control with DRV8801
Post by: JazzyJ on Apr 17, 2019, 01:56 pm
Hi, my aim is to just control the direction and speed of the Micro-Metal Gearmotor (https://www.pololu.com/product/3056/specs) with this motor driver DRV8801 (https://www.pololu.com/product/2136).

For now my code is
Code: [Select]
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?
Title: Re: DC Motor Control with DRV8801
Post by: groundFungus on Apr 17, 2019, 03:57 pm
Code: [Select]
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.
Title: Re: DC Motor Control with DRV8801
Post by: JazzyJ on Apr 17, 2019, 04:51 pm
Code: [Select]
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
Title: Re: DC Motor Control with DRV8801
Post by: JazzyJ on Apr 17, 2019, 04:56 pm
Has been solved, the solder was cold and wasn't connecting the DIR properly.