Sign in to follow this  
pjf1000

LEGO Mindstorms Elevator Programming

Recommended Posts

Hi all,

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.

 

Edited by pjf1000

Share this post


Link to post
Share on other sites

Could the Mindstorm servo motor not move the elevator up and down instead of the Power Functions motor? 

Share this post


Link to post
Share on other sites

You could try to turn the motor for a given amount of rotations or you could use a light sensor (dark = elevator in front of it; light = elevator not in front).

Share this post


Link to post
Share on other sites

Sorry for the late response, but I think I know how to code around that problem.

Try creating a loop (it could repeat indefinitely, but it really only needs to run once) and give it a unique name.

Then create a branch for each trigger within that loop, and at the end of each trigger interrupt said loop.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.