We are using a SparkFun redboard programmed with arduino for this project...
The board has 2 inputs, and the motor plugged into the first works moving both forward and backward. However, the motor plugged into the second input works only moving with the negative pin movement but starts when the positive movement should start. It completely ignores the Positive motion code.
//PIN VARIABLES
//the motor will be controlled by the motor A pins on the motor driver
const int AIN1 = 13;
const int AIN2 = 12; //control pin 1 on the motor driver for the right motor
const int PWMA = 11;
const int BIN1 = 10;
const int BIN2 = 9; //control pin 2 on the motor driver for the right motor
const int PWMB = 8;
//speed control pin on the motor driver for the right motor
//VARIABLES
int motorSpeed = 0; //starting speed for the motor
void setup() {
//set the motor control pins as outputs
pinMode(AIN1, OUTPUT);
pinMode(BIN1, OUTPUT);
pinMode(AIN2, OUTPUT);
pinMode(BIN2, OUTPUT);
pinMode(PWMA, OUTPUT);
pinMode(PWMB, OUTPUT);
}
// put for loop here
void loop () {
//drive motor forward (positive speed)
digitalWrite(AIN1, HIGH);
digitalWrite(AIN2, LOW);
analogWrite(PWMA, 255);
delay(3000);
digitalWrite(BIN1, HIGH);
digitalWrite(BIN2, LOW);
analogWrite(PWMB, 255);
delay(3000);
//drive motor backward (negative speed)
digitalWrite(AIN1, LOW);
digitalWrite(AIN2, HIGH);
analogWrite(PWMA, 255);
digitalWrite(BIN1, LOW);
digitalWrite(BIN2, HIGH);
analogWrite(PWMB, 255);
delay(3000);
}