Limit switch help!

Hi my team wants to use limit switch to change the state of a motor , but because it is our first year programming in java i am having a hard time coding some things , can someone explain to me how to where to define the limit switch and how to use it

We put them on our subsystems (for example, our indexer.). Then code a “getter” for example, isLimitSwitchClosed() on the subsystem. Then monitor the limit switch from your command. Limit switches are normally DigialInputs… I think.

1 Like

First, what are you using limit switches for? If you have a mechanism with that moves back and forth or up and down, limit switches can stop the mechanism when it reaches the minimum or maximum movement.

You mentioned changing the state of a motor when a limit switch is pressed. What kind of motor controller are you using? Some motor controllers such as talons can have limit switches plugged right into them. With other motor controllers that don’t have this feature, you would plug them into the roboRIO in a DIO port.

If you were to use a DIO port, you can use the DigitalInput class. Here’s a link to last year’s code that utilized a DigitalInput:

Here’s an example of how we use limit switches in our Climber.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.