The below code should work well to control both H-Bridges Let us know how it goes 
Set Speed to 255 for full forward
set Speed to -255 for full reverse
or anywhere in between for other speeds
set Speed to Zero for full Stop
int InputMax = 255; // Set motor Speed input range -255 to 255
int motorPin1 = 3; // pin 2 on L293D IC
int motorPin2 = 4; // pin 7 on L293D IC
int enablePinA = 5; // pin 1 on L293D IC
int enablePinB = 6; // pin 9 on L293D IC
int motorPin3 = 7; // pin 10 on L293D IC
int motorPin4 = 8; // pin 15 on L293D IC
// To Call the function
int SpeedA = 0; // Full Stop
int SpeedB = 0; // full Stop
void setup() {
// put your setup code here, to run once:
pinMode(motorPin1 ,OUTPUT);
pinMode(motorPin2 ,OUTPUT);
pinMode(enablePinA ,OUTPUT);
pinMode(enablePinB ,OUTPUT);
pinMode(motorPin3 ,OUTPUT);
pinMode(motorPin4 ,OUTPUT);
TankPWM(SpeedA,SpeedB, enablePinA ,motorPin1 ,motorPin2 , enablePinA , motorPin3 , motorPin4);
}
void loop() {
static int DirA = -1;
static int DirB = 2;
SpeedA += DirA;
SpeedB += DirB;
TankPWM(SpeedA,SpeedB, enablePinA ,motorPin1 ,motorPin2 , enablePinA , motorPin3 , motorPin4); // Call the motor Dirve Function
delay(10);
if(abs(SpeedA) >= 255) DirA = -1*DirA; // Reverse counter
if(abs(SpeedB) >= 255) DirB = -1*DirB; // Reverse counter
}
void TankPWM(int16_t LeftDrive,int16_t RightDrive, uint8_t LeftPin, uint8_t Forward_LeftPin , uint8_t Reverse_LeftPin, uint8_t RightPin, uint8_t Forward_RightPin, uint8_t Reverse_RightPin ){
static int16_t LastLeftDrive;
static int16_t LastRightDrive;
if ((LeftDrive == 0) ||((LastLeftDrive > 0) != (LeftDrive > 0))){
digitalWrite(Forward_LeftPin, LOW);
digitalWrite(Reverse_LeftPin, LOW);
// Add Breaking
}
if ((RightDrive == 0) ||((LastRightDrive > 0) != (RightDrive > 0))){
digitalWrite(Forward_LeftPin, LOW);
digitalWrite(Reverse_LeftPin, LOW);
// Add Breaking
}
//Add Slow Ramp up to Speed to Prevent sudden changes in direction of motor
LastLeftDrive = LeftDrive;
LastRightDrive = RightDrive;
analogWrite(LeftPin,constrain(map(abs(LeftDrive),0,InputMax ,0,255),0,255));
analogWrite(RightPin,constrain(map(abs(RightDrive),0,InputMax ,0,255),0,255));
if(LeftDrive < 0){
digitalWrite(Forward_LeftPin, HIGH);
digitalWrite(Reverse_LeftPin, LOW);
}
if(RightDrive < 0){
digitalWrite(Forward_RightPin, HIGH);
digitalWrite(Reverse_RightPin, LOW);
}
if(LeftDrive > 0){
digitalWrite(Forward_LeftPin, LOW);
digitalWrite(Reverse_LeftPin, HIGH);
}
if(RightDrive > 0){
digitalWrite(Forward_RightPin, LOW);
digitalWrite(Reverse_RightPin, HIGH);
}
}
Z