Multiple button press choices

hi,
I am still fairly new to programming and have trawled through pages of example code trying to find something similar to what I want to achieve but can't quite work this out.

I am using dueminalove with a motor shield/stepper motor. I have four push switches, let's say named SetupA, SetupB, StartA, StartB.

The end objective is to have my stepper motor, on pushing the relevant switch (setupA or B), move to one of its two starting positions then wait for the relevent start switch to be pressed (StartA or B) which then run through different motor sequences.

Code-wise this is what I am trying to achieve-

On power up I want the code to wait for input from either SetupA or SetupB switches.

When either is pressed it runs the relevent bit of code, say SetupCodeA or SetupCodeB, (getting the motor to one of the two start positions)

Then after running the relevant code it waits for an input from the StartA or StartB switch

When Start A or B button is pressed it runs either StartCodeA or StartCodeB (starting the motor on one of the two start sequences)

I am trying to work out exactly what statements to use to achieve or 'call' the different bits of code then wait. My understanding is that I may need to use a switch/case statement but don't quite understand how to implement it in this case.

I don't have any problems with the rest of the setup, it is just the 'using different switches to run different code' that is confusing me.

Any help or pointers to something similar would be appreciated.

Pretty basic stuff there:

byte setupAswitch = 2;// define pins to be used
byte setupBswitch = 3;
byte startAswitch = 4;
byte startBswitch = 5;

byte mode; // 0 = waiting to start, 1 = setupA, 2 = setupB, 3 = post setup, pre-startup, 4 = A code, 5 = Bcode, 6 = post A/B startup code
void setup(){
pinMode (setupAswitch, INPUT);
digitalWrite (setupAswitch, HIGH); // turn on internl pullup - check for a LOW input to indicate switch is closed to ground
pinMode (setupBswitch, INPUT);
digitalWrite (setupBswitch, HIGH);
pinMode (startAswitch, INPUT);
digitalWrite (startAswitch, HIGH);
pinMode (startBswitch, INPUT);
digitalWrite (startBswitch, HIGH);
void loop(){
if (mode ==0 && digitalRead(setupAswitch) == LOW){ mode = 1;}
if (mode == 0 && digitalRead(setupBswitch_ == LOW) {mode = 2;}
if ( mode == 3 && digitalRead (startAswitch) == LOW){ mode = 4;}
if ( mode == 3 && digitalRead (startBswitch) == LOW){ mode = 5;}
switch (mode){
case 0:
// do nothing
break;
case 1:
// A setup code
mode = 3;
break;
case 2:
// B setup code
mode = 3;
break;
case 3:
// do nothing
break;
case 4:
// A start code
mode = 6;
break;
case 5:
// B start code
mode = 6;
break;
case 6:
// whatever is done after setup & start
break;
} // end switch

} // end loop

Wow, thankyou so much. It is so helpful to see it like this.

A quick question, where I have case 0 and case 3 (the holding/waiting points) do I need to define anything here to hold it at this point or just leave it blank as you have - is there an 'indefinite wait until input' command I need to put in there?

Thanks again

is there an 'indefinite wait until input' command I need to put in there?

No.

There are times when you want to do something.

The rest of the time, you do NOT want to do nothing. You want to keep checking to see if it is time to do something (i.e. the user pressed a switch).

I only put 0 & 3 there to avoid the question of "what happened to case 0 & 3?"
In both cases, the software is to just keep checking for the next keypress.
Both could have been left out altogether as no action is taken inside them.