Running two or more switch cases "at the same time"

Hey guys, I was wondering if it's possible to run one switch case, then run another one in parallel? For example, if I want to have one motor running at a certain speed, then change rotation direction of another motor whilst the first one is still running.

Really in parallel? Probably not unless you use something with multiple cores. In parallel enough that you can't tell that it's not? Sure.

Yes, however you can not perform any actions in either switch case, that will "block" (trap the processor in a loop where it can't do any other tasks). Your question is a little abstract, please give an example. A detailed scenario, not just a few words about some motors...

You can do what you want, but the switch-cases are probably not the sollution.

The several things at a time tutorial might help.

Duff's Device?

Best method is...

  1. Learn how to program in C/C++
  2. Understand how both your sketches work
  3. Implement both sketches as a single combined sketch

Since the way people usually wish to “combine sketches” involves some interaction between those sketches, and/or at least one of the sketches involves delay, any other approach Is virtually doomed to failure.

Thank you so much everyone for the advice and links. I'm going to check out those examples that some of you guys posted above. They do seem to be on the right track in terms of what I want to achieve.

well it's basically configured like this... I want the user to be able to increase rotation of 3rd stepper motor whilst stepper 1 and stepper 2 are doing their thing.

void loop(){
     
     switch (state) {

        case 'a':
        //run oscillate function for stepper 1
        //run rotation function for stepper 2


        //increase rotation of stepper 3 by a specified amount in a specific direction each time a user presses a 
           certain button (or rather each time a specific character is entered in serial monitor).

        break;


}

}