ElapsedTime Logic
For now our goal will be to have the motors move forward for 3 seconds. To accomplish this we need to edit our main While Loop so that it triggers when the OpMode is active AND the ElapsedTime timer is less than or equal to 3 seconds.
Let's take a look first at how our timer appears in OnBot Java when checking for less than or equal to 3 seconds:
When using our default template, our program will continue running until we press stop on the Driver Hub. However, in this situation we want our program to end when our timer is up. This means we need to modify our while loop to add a second condition!
Alongside our check for opModeIsActive() we will add our check for if runtime is under 3 seconds:
Now the While Loop will now activate when both conditions of the AND block are true.