View Single Post
  #4   Spotlight this post!  
Unread 17-01-2014, 15:11
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
Re: Programming Limit Switch

Quote:
Originally Posted by notmattlythgoe View Post
What Signet said.

Also, if you ware using the Command Based structure with Java you can set the limit switch up to act as a button to fire a command.

Code:
final DigitalInput limitSwitch = new DigitalInput(1);
Button limitSwitchButton = new Button() {
     public boolean get() {
           return limitSwitch.get();
     }
};
limitSwitchButton.whenPressed(new SomethingCommand());
Actually there is already a class for this in WPILib: DigitalIOButton.

So you just need:
Code:
Button limitSwitchButton = new DigitalIOButton(1);
limitSwitchButton.whenPressed(new limitSwitchCommand());
__________________
Programmer - A creature known for converting Caffeine into Code.
Studying Computer Science @ Louisiana Tech University
Associate Consultant @ Fenway Group

2012-13: 3946 - Head of Programming, Electrical and Web
2014 - 3468 - Programming Mentor
2015 - Present - Lurker
Reply With Quote