Need a little help with Program Structure if anyone feels so kind.
I have a three switches ULS, UTS and LLS, which are U.pper L.imit S.witch, U.pper T.ag S.witch and L.ower L.imit S.witch respectively.
And a Stepper Motor connected to my Arduino Mega via a Gecko 203V which needs step and direction inputs.
Functionally all tests out fine. Motor turns CW and CCW as instructed at proper velocity. All three(3ea) switches toggle their respective bits no problem.
So here's the question.
I want to perform a digitialRead on ULS and UTS and perform the following:
Scenario 1: If UTS is LOW Output a HIGH on Pin 19 which effectively moves the motor CW until either UTS goes HIGH ULS goes HIGH
Scenario 2: If ULS goes HIGH ((and BTW if this happens their is no way for UTS to EVER go HIGH simultaneously)) output a LOW on Pin 19 Driving the motor CCW until LLS finally goes HIGH at which point the motor sits there until an operator resets the unit.
Here's my problem. If I try and perform Scenario 2 it competes with Scenario 1 trying to Force UTS HIGH.
basically, ignoring everything here, I need an example of a BASIC If THIS then do THIS, If This Other Thing, then do This Other Thing
Trying to stack of functional 'voids' just is the wrong way to do this....
...or is it?
Thanks All.