Programming Limit Switch

I have no idea how to program a limit switch. If anyone could give me an example or link on how to program one it would be appreciated.

What are you doing with it?

Here’s the basic code:

DigitalInput limitSwitch;

    public RandomSubsystem() {
        
        limitSwitch = new DigitalInput(1);     //1 = the DIO port of the sensor
    }

   public boolean getLimitSwitch() {
        return limitSwitch.get();
    }

   public void doSomething() {
        if(getLimitSwitch() == false) {
             doSomething();
        }
    }

Then call doSomething() from a command and set the isFinished() method to trigger when getLimitSwitch() returns true.

FWIW, if you plug it directly into a Jag you don’t need to program it.