Programming Structure

Hey folks,

I'm setting up a smaller device that has 2 inputs (momentary button and sensor) and it will run two different motors. After the momentary button is pushed (cycle start), I'd like the motors to run for X seconds but stop earlier if the sensor value gets within a specific range. I've been hacking away with various forms of if and else and delays but the program gets locked into the delay until the delay is finished instead of running and constantly reading the value from the sensor.

Is this a situation where case is used? I'm not sure what to even look up as far as best practice is concerned.

-VW

(deleted)

See Using millis() for timing. A beginners guide, Several things at the same time and look at the BlinkWithoutDelay example in the IDE.

Learn about state machines and event loops...