Implement Variable in Variablename?

Hello,
I have a problem while programming for a project:
I have the stepper motors “s1”, “s2”, “s3”…
Now I want to make a function to turn the motors as long as the button “b1”, “b2”, “b3”… isn’t pressed.

void turnStepperUntilButtonPressed (char Number) {
while (digitalRead(b<-"Number" here->) == LOW) {
s<-"Number" here->.step(1024);
}
}

How do I replace the “<-“Number” here->” with the variable “Number”?

Thank you for your help.

Vantezzen

I think you need to look at arrays

Yes, you can do that easily with arrays

...R

When the compiler does its stuff, names are replaced with addresses. At runtime, there is no concept of a variable called s1. There is an address associated with the instance.

By putting the Stepper instances in an array, the addresses are then adjacent in memory, so you can use s[n].step() to make the nth instance dance.

Sorry, but I'm not very familiar with arrays :) How do I get this: Stepper s1(einedrehung, s11, s12, s13, s14); Stepper s2(einedrehung, s21, s22, s23, s24); [...] into an array? Stepper s = {};

How do I get this: Stepper s1(einedrehung, s11, s12, s13, s14); Stepper s2(einedrehung, s21, s22, s23, s24); [...] into an array? Stepper s = {};

Stepper s[] = { Stepper(einedrehung, s11, s12, s13, s14),
                       Stepper(einedrehung, s21, s22, s23, s24) };

is one way.

Thank you :)