|
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.
|