View Single Post
  #3   Spotlight this post!  
Unread 11-02-2013, 22:56
arithehun arithehun is offline
Registered User
AKA: Ari Falkner
FRC #3024
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Ashland, Oregon
Posts: 27
arithehun is an unknown quantity at this point
Re: Timer for solenoid?

There are a few methods. You could used command based programming, and then use it as such (assuming you're using a spike relay, aka bridge driver to control the solenoid):

Code:
public ShootFrisbee() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(shooterSubsystem);
        setTimeout(0.25);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        shooterSubsystem.shootSolenoid(Relay.Value.kOn);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return isTimedOut();
    }

    // Called once after isFinished returns true
    protected void end() {
        shooterSubsystem.shootSolenoid(Relay.Value.kOff);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
If you want to just use the SimpleRobot, then using java's built in delay command should work (solenoid is the relay object in this block)

Code:
solenoid.set(Relay.Value.kOn);
wait(0.25);
solenoid.set(Relay.Value.kOff);
Of course, the second example's block of code should be run in a separate thread so the wait(0.25) function does not clog up your robot's "docket".

Last edited by arithehun : 11-02-2013 at 23:03.
Reply With Quote