combining code help

I'm trying to run a DC motor and have a speaker play sound at the same time or have the speaker play then motor run at separate times in a loop.

I'm using the code here for the speaker High-Low Tech – Simple Arduino audio samples
heres what I'm using for the dc motor http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/step4/One-Motor/

the problem is they're both using Pwm pins is there a way to let them use them alternate which code runs ?

the problem is they're both using Pwm pins is there a way to let them use them alternate which code runs ?

Why is that a problem? You have several PWM pins.

the motor shield I’m using seems to be using all of them

the motor shield I'm using seems to be using all of them

Covering and using are two different things. Which motor shield do you have? I seriously doubt that is uses all 6 PWM pins.

/*************************************************************
Motor Shield 1-Channel DC Motor Demo
by Randy Sarafan

For more information see:
http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/

*************************************************************/

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

void loop(){
  
  //forward @ full speed
  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255);   //Spins the motor on Channel A at full speed
  
  delay(3000);
  
  digitalWrite(9, HIGH); //Eengage the Brake for Channel A

  delay(1000);
  
  //backward @ half 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
  
  delay(3000);
  
  digitalWrite(9, HIGH); //Eengage the Brake for Channel A
  
  delay(1000);
  
}

is your motor code, and a quick glance looks like your accessing 3 pins 3 9 and 12..

check your shield documentation to see if it is reserving any other pins for any reason..
if not select one or more unused to assign for your other functions..

probably find 10, 11 are reserved for chanel B but if your not using chanel B chances are u can pass through the shield ok unless the documentation for it states otherwise?