The fact remains that neither sketch uses 3 pins defined as outputs to control the shield.
Motor channel A uses pin 12 to control direction, pin 9 for braking and pin 3 to control speed whilst motor channel B uses pin 13 to control direction, pin 8 for braking and pin 11 to control speed. Pins A0 and A1 are used for current sensing if required, but are not necessary unless current sensing is needed.
There are a number of things wrong with your sketch such as reading an analog value from the bump pins then testing whether the value(s) are HIGH. This could work but it would be more normal to read the digital value and test it for HIGH/LOW.
In this snippet
pinMode(12, OUTPUT);
pinMode(9, OUTPUT);
pinMode(13,OUTPUT);
pinMode(8,OUTPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
}
void loop() {
val = analogRead(bumpPin1);
randNumber = random(600, 1500);
if (val == HIGH) { // if no objects detected on bump sensor right
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
digitalWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
digitalWrite(11, 255); //Spins the motor on Channel B at full speed
pins 3 and 11 are used as outputs but are not defined as such.
You need to start with simple sketches that run the motor(s) and work from there
Try this
int motorA_dir = 12; //direction
int motorA_brake = 9; //brake
int motorA_speed = 3; //speed
void setup()
{
pinMode (motorA_dir, OUTPUT); //set 3 pins to be outputs
pinMode (motorA_brake, OUTPUT);
pinMode (motorA_speed, OUTPUT);
digitalWrite(motorA_dir,HIGH); //direction 1
digitalWrite(motorA_brake,LOW); //brake off
for (int motorSpeed = 0;motorSpeed <=255 ;motorSpeed++)
{
analogWrite(motorA_speed, motorSpeed); //set the motor speed
delay(100); //slow down the for loop a little
}
analogWrite(motorA_speed, 0); //let the motor coast to a stop
}
void loop()
{
}
One motor should run up from its slowest speed to its highest then stop. Note how giving the Arduino pins names helps to make the code more readable.