FIRST Robotics Competition Discussions

Showing results for 
Search instead for 
Did you mean: 

programing switch

how to program a micro switch to stop when a part of the elevator touches it and deactivates the motor that causes the elevator to rise

0 Kudos
Message 1 of 3

If this is for a software-only project as an exercise, then just monitor the microswitch via some communication method (or with Events) and disable the elevator movement in the switch direction when the switch is active.


If this is for a real elevator, please take care to consider logic directions and the effects of e.g. broken wires and shorts on your elevator. I expect there are specific safety standards in your country that govern how such a system should be connected, and may also describe (in at least some form) the appropriate software behaviour.


For example, in the case I described for the software exercise, a short in the wire would prevent the elevator moving (which might be frustrating for passengers) but a broken wire might allow your elevators' motors to keep trying to drag it into the ceiling - potentially much more dangerous?

0 Kudos
Message 2 of 3

You're talking about the idea of a limit switch.  A limit switch sends a digital response (T or F, 1 or 0) so you can use that to modify your logic.


However, it's important to be aware disabling the motor means there's now nothing driving the elevator up but gravity is still pulling it down.  You'll need to do something to determine how you'll keep it up.


The base part of your question is "read the digital value of the switch and use that to modify the output."  I assume you're using a button to start the movement.  At which point, you'd have it move the elevator until it reads the true/false value of the limit switch and then stops driving the motor.  Though, it's hard to say without looking at what you're doing with your code.

0 Kudos
Message 3 of 3