I have a LEGO office building with an elevator. I've automated the elevator with a mindstorms touch sensor. The program starts by descending down the elevator shaft until it sits on top of the touch sensor at the bottom of the elevator shaft. Ideally, the touch sensor is supposed to trigger the mindstorms motor to turn in the opposite direction and pull the elevator back up for fifteen seconds. The mindstorms motor turns again in the opposite direction, so the elevator descends down again to hit the touch sensor. (The process repeats indefinitely) In a vacuum, this program works fine. However, I've had numerous issues with the sensor not triggering, and the elevator eventually winds in the wrong direction and binds with the roof, breaking. I've tried making the elevator heavier, but it still has issues.
I want to program a fail safe so that it will bypass the first wait block or cut off the program if the touch sensor doesn't trigger within a certain timeframe. I've included a picture of my current program. Within the infinite loop, I want the loop to start by waiting for the touch sensor to be pressed, then executing the two other motor commands I have following it. While the program is waiting for the touch sensor to be pressed, I want another thread to wait for twenty seconds. If the touch sensor is not pressed within that timeframe, I want the program to bypass the first touch sensor wait block and continue with the last two motor rotations (then repeat). I've been able to branch off into two different coding threads within one program, but I can't recombine the two inputs into the beginning of one block. How do I do this or accomplish my goal in another way? I'm at a convention right now and I really just want this to work.
Some more information, the mindstorms motor is connected to a control switch, which tells my power functions motor which way to turn. That's why the mindstorms motor rotations are so short.
Thank you everyone for your help.