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.
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?
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.