Need help with a limit switch

We are trying to add a limit switch on two spots of our lift system for our arms. We want one at the top and bottom, however we don’t know how to attach the limit switch and get Boolean values from it. If anyone knows can you please reply?

Limit switches have up to 3 contacts on them - a “common”, a “normally open” (NO) and a “Normally Closed” (NC). Take a PWM wire and hook up the white (signal) and black (ground) wires to the limit switch. One should go to the “common” connector, the other to one of the other two, depending on how you want it to work in the code:

  • A NO connection would mean the switch is “true” when not pressed and false when pressed.
  • A NC connection would mean the switch is "false"when not pressed and “true” when pressed.

The roboRIO has a pull-up resistor in all of the digital inputs, so the input “sees” 5V normally, and only when the signal pin is connected to ground will it " see" ground.

Once you get the switch hooked up, plug it into one of the DIO ports.

In the code, create a DigitalInput and read the value - it’ll return a Boolean true/false.

Do I need to import anything else other than the talon in my code?

limit switch threads that might be helpful
The DigitalInput is the way they use to detect the inputs of the limit switch. There is a lot of good info on the WPILIB FRC provides if you can navigate it.