View Single Post
  #6   Spotlight this post!  
Unread 30-01-2013, 12:51
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: LimitSwitch as Command Button

It is quite easy actually. You just extend Button and implement your own get() method to return the limit switch input. Add your own debouncing and you are good.

Here is my code (I haven't implemented any debouncing)

Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.frc3946.MyTest;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.buttons.Button;

/**
 *
 * @author Gustave Michel
 */
public class IOButton extends Button {
    DigitalInput button;
    
    public IOButton(int port) {
        button = new DigitalInput(port);
    }
    
    public boolean get() {
        return button.get();
    }
    
}
__________________
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