View Single Post
  #1   Spotlight this post!  
Unread 20-11-2015, 11:15
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
AKA: Sam Carlberg
no team
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 103
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: How to time an action in teleop without delaying teleop.

You can use java.util.Timer and java.util.TimerTask to schedule something to happen in the future while your program still runs.

Code:
// local or class variables
final int solenoidDelay = 65; // milliseconds
final Timer myTimer = new Timer();
final TimerTask closeSolenoidTask = new TimerTask() {

    @Override
    public void run() {
        closeSolenoid();
    }
};

...

mySolenoid.open();
myTimer.schedule(closeSolenoidTask, solenoidDelay);
__________________
WPILib
GRIP, RobotBuilder

Last edited by SamCarlberg : 20-11-2015 at 11:17.
Reply With Quote