View Single Post
  #5   Spotlight this post!  
Unread 18-02-2012, 18:28
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Need some quick advice

in OI:

Code:
JoystickButton doStuff = new JoystickButton(joysticknumber, buttonnumber);

doStuff.whenReleased(new Shoot());
Make a command called Shoot
Code:
package edu.wpi.first.wpilibj.templates.commands;

/**
 *
 * @author Thundrio
 */
public class ExampleCommand extends CommandBase {
Timer t = new Timer();


    protected void initialize() {
        shooterMotors.set(1);
        t.reset();
        t.start();
    }

    protected void execute() {
        shooterMotors.set(1);
        if (t.get() >= 1)
            solenoid.extend();
    }

    protected boolean isFinished() {
        if (solenoid.isExtended())
            return true;
        else
            return false;
    }

    protected void end() {
        shooterMotors.set(0);
    }
}
Something like that. Replace the placeholder stuff with your own commands and subsystems obviously, and add a constructor and all.
Reply With Quote