help with combining code of speaker and motor

Can someone please help me fix my code?

Basically, a user inputs values that determine how many beeps will play from a breadboard-compatible speaker, and right after the beeps are played, a motor (connected to the breadboard) is supposed to turn.

The beep-code is mine, and I got the motor code from the Arduino website. Anyway, SEPARATELY the codes work – the beeps play from the speaker, the motor turns fine. However, the codes don’t work when I combine them, and I have no idea how to fix it. Any help is appreciated. Thanks so much.

int pin = 3;
#include <Stepper.h>


                   
void setup() {
  Serial.begin(9600);
}


void loop() {


int bpmeasure, measurespg, bpminute;

Serial.println("Enter number of beats per measure:"); 
      while (Serial.available() == 0){
      };
      bpmeasure = Serial.parseInt();
      Serial.println(bpmeasure);
      
Serial.println("Enter number of measures on page:"); 
      while (Serial.available() == 0){
      };
      measurespg = Serial.parseInt();
      Serial.println(measurespg);

Serial.println("Enter tempo:");
      while (Serial.available() == 0){
      };
      bpminute = Serial.parseInt();
      Serial.println(bpminute);
      
float tppg = (bpmeasure * measurespg * 60000.0) / bpminute; // time it takes to play a page, in milliseconds
float tpbeat = tppg / (bpmeasure * measurespg); // time between each individual note, in milliseconds
float t = 0.0;

for (float t = 0.0; t <= tppg ; t += tpbeat) { 
     tone (pin, 30, 50);
     delay (tpbeat+50);
     } // speaker is supposed to beep every 'tpbeat' amount of milliseconds, until it reaches 'tppg' milliseconds and then speaker should stop beeping

     
const int stepsPerRevolution = 900;  

Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0;  // number of steps the motor has taken

if (stepCount = 0) {
// read the sensor value:
  int sensorReading = analogRead(A0);

  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);

  // set the motor speed:
  if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);

    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 100);
  }
     
  }
}

Exactly what happens when "the codes don't work when I combine them"? Please describe in detail what currently happens compared to what you would like to happen.

From what I can see the motor stepping code is incomplete- the variable "stepcount" is always going to be 0 so whats the point of testing its value? As it stands I imagine the motor will run continously unless there is 0 voltage on A0.

Did you check the value of sensorReading and motorSpeed? Put some Serial.println() statements in there so you can see whats going on..

Otherwise comment out all except the motor code and see if it works on its own.