|
Re: What is the point of timer.delay?
The Timer.delay(); function allows the robot to activate a value and reset.
For example:
driveTrain.tankDrive(motor1, motor2);
Timer.delay(0.005);
This allows the drivetrain to refresh the motors at 5 ms(aka stop on a dime!)
OR
if(joy1.getRawButton(1))
{
move_motor = true;
}
Timer.delay(0.5);
if(move_motor == true)
{
motor.set(1.0);
}
Timer.delay(0.005);
This allows button 1 to change position only after every half second if the code changes. So the button held will not change if the button is hit again for 0.5 seconds.
Hope this helped.
P.S. The placement of the Timer.delay() is very important because having a drive train after a time greater than, for example, .15 seconds, will start to see a very small twitch in activating the motors and cause it to slow down and start up at intervals. It can get weird!
Happy Competition!
__________________
Team 1369
Senior
Head Programmer (Java)
Head Electrician
|