help w/ detecting problem in code for metronome-motor project

Problem: I want my code to control how many beeps are emitted from a speaker (mounted onto a breadboard) based on user input, and right after all the beeps are played, a stepper motor to turn. I'm not focusing on how to stop the motor after a period of time or make it turn counterclockwise or whatever - I just want it to turn first. As of now, the metronome part of the code works fine, but then nothing happens after the beeps. The motor does not turn like I want it to. My code is below.

int pin = 8;
int bluePin = 2;
int greenPin = 3;
int yellowPin = 4;
int orangePin = 5;

int currentStep = 0;

                   
void setup() {
  Serial.begin(9600);
  tone (pin, 30, 50);

    
  pinMode(bluePin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(orangePin, OUTPUT);

  digitalWrite(bluePin, LOW);
  digitalWrite(greenPin, LOW);
  digitalWrite(yellowPin, LOW);
  digitalWrite(orangePin, LOW);
}


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

  
switch(currentStep) {
    case 0:
       digitalWrite(bluePin, HIGH);
       digitalWrite(greenPin, LOW);
       digitalWrite(yellowPin, LOW);
       digitalWrite(orangePin, LOW);
       break;
       
    case 1:
       digitalWrite(bluePin, LOW);
       digitalWrite(greenPin, HIGH);
       digitalWrite(yellowPin, LOW);
       digitalWrite(orangePin, LOW);
       break;
       
    case 2:
       digitalWrite(bluePin, LOW);
       digitalWrite(greenPin, LOW);
       digitalWrite(yellowPin, HIGH);
       digitalWrite(orangePin, LOW);
       break;
       
    case 3:
       digitalWrite(bluePin, LOW);
       digitalWrite(greenPin, LOW);
       digitalWrite(yellowPin, LOW);
       digitalWrite(orangePin, HIGH);
       break;
    
  }

currentStep = (++currentStep < 4) ? currentStep:0;
  delay (10);


}

I looks like you are using a stepper motor? If so, the Stepper library that comes with the IDE might make your life easier.

In your code, the switch statement runs through only once per loop(). If you want the motor to run, put the switch, increment step and delay in its own loop. A for loop to run a certain number of steps or a while loop to run til a condition is met (button push?).

I added a for loop

 for (int currentStep = 0; currentStep < 2000; currentStep++) {
  
switch(currentStep) {
    case 0:
       digitalWrite(bluePin, HIGH);
       digitalWrite(greenPin, LOW);
       digitalWrite(yellowPin, LOW);
       digitalWrite(orangePin, LOW);
       break;
       
    case 1:
       digitalWrite(bluePin, LOW);
       digitalWrite(greenPin, HIGH);
       digitalWrite(yellowPin, LOW);
       digitalWrite(orangePin, LOW);
       break;
       
    case 2:
       digitalWrite(bluePin, LOW);
       digitalWrite(greenPin, LOW);
       digitalWrite(yellowPin, HIGH);
       digitalWrite(orangePin, LOW);
       break;
       
    case 3:
       digitalWrite(bluePin, LOW);
       digitalWrite(greenPin, LOW);
       digitalWrite(yellowPin, LOW);
       digitalWrite(orangePin, HIGH);
       break;
    
  }

currentStep = (++currentStep < 4) ? currentStep:0;
  delay (1000);

  }

}

and the motor moves! thank you! However, all four LEDs (on the darlington board that controls the motor) are supposed to light up, and only 2 of them do. The LEDs are controlled by pins 2, 3, 4, and 5. Any idea how to fix this?

for (int currentStep = 0; currentStep < 2000; currentStep++) {
  
switch(currentStep)

You have 2 different variables with the same name. The indexer of the for loop and the variable that keeps track of steps. Change one (hint: for(int n = 0; n < 2000; n++). That may solve the strange behavior.

Thank you so much!!