Hello, i am trying to use the TB9051FTG motor driver to control my motor but i am unable to get it to work. I am running a simple code to see if i have my connections right. So far i am using four pins to control the motor. I have GND to GND, EN to pin 3, PWM1 to pin 4, and PWM2 to pin 5. I have the motor leads connected to out 1 and out 2. I have a 10.2 V source connected to Vin. I am not sure if im using the pins correctly or if im using all the ones i need too.
The board that i am using is the arduino MKR zero. Any help will be appreciated.
const int EN = 3;
const int PWM1 = 4;
const int PWM2 = 5;
void setup()
{
//set all pins as output
pinMode(PWM1, OUTPUT);
pinMode(PWM2, OUTPUT);
pinMode(EN, OUTPUT);
}
void loop()
{
//drive forward at full speed by pulling PWM1 High
//and PWM2 low, while writing a full 255 to EN to
//control speed
digitalWrite(PWM1, HIGH);
digitalWrite(PWM2, LOW);
analogWrite(EN, 255);
//wait 1 second
delay(1000);
//Brake the motor by pulling both direction pins to
//the same state (in this case LOW). PWMA doesn't matter
//in a brake situation, but set as 0.
digitalWrite(PWM1, LOW);
digitalWrite(PWM2, LOW);
analogWrite(EN, 0);
//wait 1 second
delay(1000);
//change direction to reverse by flipping the states
//of the direction pins from their forward state
digitalWrite(PWM1, LOW);
digitalWrite(PWM2, HIGH);
analogWrite(EN, 150);
//wait 1 second
delay(1000);
//Brake again
digitalWrite(PWM1, LOW);
digitalWrite(PWM2, LOW);
analogWrite(EN, 0);
//wait 1 second
delay(1000);
}