Limit Switches
Limit switches have many uses on a robot or mechanism.
Limit Switch Pinout
The inputs on the VMX FlexDIO and Titan are pulled high, with the Titan having hardware debounce correction. When wiring the limit switch it is recommended to wire ground to common and signal to normally open.
Limit Switch Configuration
The limit switch has three ways it can be configured for use.
Default |
Forward |
No Roller |
|---|---|---|
Programming
Limit Switches are read as a digital input. If wired correctly per the pinout section above, when a switch is activated it will show as low or false.
1//import the DigitalInput Library
2import com.wpi.first.wpilibj.DigitalInput;
3
4//Create the DigitalInput Object
5private DigitalInput input;
6
7//Constuct a new instance
8input = new DigitalInput(port);
9
10//Can then use these accssor to get data
11input.get(); //Will return true for a high signal and false for a low signal
Header
1//Include the DigitalInput Library
2#include "frc/DigitalInput.h"
3
4//Constructors
5frc::DigitalInput input{port};
Source
1//Use these to access data
2input.Get(); //Will return true for a high signal and false for a low signal