View Single Post
  #2   Spotlight this post!  
Unread 24-02-2013, 16:56
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Programming Limit Switch

Quote:
Originally Posted by Mr.Roboto3335 View Post
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:

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.
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote