|
Re: Need help with a limit switch
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.
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
|