Running 2 Dc motors simultaneously

Hi!
I recently bought my first arduino uno, a power shield and 2 motors. Today i thought i was gonna build a car but couldnt manage to make the motors run simultaneously. I’m new to this so i got help with the code from a website;

void setup() {
  
  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin

  //Setup Channel B
  pinMode(13, OUTPUT); //Initiates Motor Channel A pin
  pinMode(8, OUTPUT);  //Initiates Brake Channel A pin
  
}

void loop(){

  
  //Motor A forward @ full speed
  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 123);   //Spins the motor on Channel A at full speed

  //Motor B backward @ full speed
  digitalWrite(13, LOW);  //Establishes backward direction of Channel B
  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
  analogWrite(11, 123);    //Spins the motor on Channel B at half speed

  
  delay(3000);

  
  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(9, HIGH);  //Engage the Brake for Channel B


  delay(1000);
  
  
  //Motor A forward @ full speed
  digitalWrite(12, LOW);  //Establishes backward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 123);    //Spins the motor on Channel A at half speed
  
  //Motor B forward @ full speed
  digitalWrite(13, HIGH); //Establishes forward direction of Channel B
  digitalWrite(8, LOW);   //Disengage the Brake for Channel B
  analogWrite(11, 123);   //Spins the motor on Channel B at full speed
  
  
  delay(3000);
  
  
  digitalWrite(9, HIGH);  //Engage the Brake for Channel A
  digitalWrite(9, HIGH);  //Engage the Brake for Channel B
  
  
  delay(1000);
  
}

Does anyone noone what it is that im doing wrong? Im powering it through the USB port of my pc atm and when its a car im gonna power it with a 9V battery that connected not to the power shield but directly to the arduino board with a converter.
Thanks!

Samuel72718:
Does anyone noone what it is that im doing wrong? Im powering it through the USB port of my pc atm and when its a car im gonna power it with a 9V battery that connected not to the power shield but directly to the arduino board with a converter.

First of all thank you for posting your code properly, Many newbies don't bother.

You have not really told us what happens when you run that program.

You must NOT power any motor through an Arduino board, it cannot provide enough current and you may damage the Arduino.

One of those small PP3 style 9v batteries is completely useless for powering motors, or even an Arduino on its own. They cannot provide enough current. Try a pack of 6 x AA cells.

Post a link to the datasheet for the motor shield you are using and a diagram of how you have everything connected. A photo of a simple pencil drawing is probably best. See this Simple Image Guide

...R

This forum really ought to have automatic recognition of posts with "9V" and "motor" both in the text,
since this is a very common issue people stumble into

Small 9V batteries are for low current only, and motors are never low current...