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

http://www.chiefdelphi.com/forums/showthread.php?t=134445&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=134319&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=134380&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=134326&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=134325&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=134298&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=133601&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=134205&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=133983&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=133065&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=133697&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=133452&highlight=limit

http://www.chiefdelphi.com/forums/showthread.php?t=132966&highlight=limit

http://wpilib.screenstepslive.com/s/4485/m/13809/l/241867-switches-using-limit-switches-to-control-behavior
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.