int dirA = 12;
int speedA = 3;
int brakeA = 9;

int dirB = 13;
int speedB = 11;
int brakeB = 8;

void setup() {

  pinMode(dirA, OUTPUT);
  pinMode(speedA, OUTPUT);
  pinMode(brakeA, OUTPUT);

  pinMode(dirB, OUTPUT);
  pinMode(speedB, OUTPUT);
  pinMode(brakeB, OUTPUT);

  // disable brakes
  digitalWrite(brakeA, LOW);
  digitalWrite(brakeB, LOW);

  // set directions
  digitalWrite(dirA, HIGH);
  digitalWrite(dirB, HIGH);
}

void loop() {

  // pulse motors out of sync
  for(int speed = 0; speed <= 255; speed++) {

    analogWrite(speedA, speed);        // Motor A speeds up
    analogWrite(speedB, 255 - speed);  // Motor B slows down
    delay(10);

  }

  for(int speed = 255; speed >= 0; speed--) {

    analogWrite(speedA, speed);        // Motor A slows down
    analogWrite(speedB, 255 - speed);  // Motor B speeds up
    delay(10);

  }

}