Timer#
Introduction#
VEXcode VR has a timer that keeps track of elapsed time from the start of a project. It can be used to measure how long something takes, trigger events after a set time, or reset for new timing operations.
Below is a list of all available blocks:
reset timer – Resets the timer to zero.
timer in seconds – Reports how much time has passed.
when timer – Runs a stack of blocks after the timer exceeds a specified time.
reset timer#
The reset timer stack block resets the timer to zero. This can be used to start timing a new part of a project without restarting the whole project.
reset timer :: custom-orientation
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started :: hat events
[Display the time the robot takes to turn right.]
drive [forward v] for (200) [mm v] ▶
reset timer :: custom-orientation
turn [right v] for (90) degrees ▶
set print precision to [0.1 v]
print [Turn right took] ◀ and set cursor to next row
print (timer in seconds) ▶
print [ seconds] ▶
timer in seconds#
The timer in seconds reporter block reports the time since the timer was last reset, as a decimal in seconds. The timer is automatically reset at the start of a project. This block can be used to time how long it takes the robot to complete different actions.
(timer in seconds)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started :: hat events
[Display the time it takes to move in a square.]
repeat (4)
drive [forward v] for (100) [mm v] ▶
turn [right v] for (90) degrees ▶
end
set print precision to [0.01 v]
print (timer in seconds) ▶
when timer#
The when timer hat block runs the attached stack of blocks after a specified amount of time.
when timer > [1] seconds :: hat events
Parameters |
Description |
|---|---|
time |
Specifies the number of seconds before the attached stack of blocks starts. Accepts both whole and decimal numbers. |
Example
when timer > [2] seconds :: hat events
[Drive after 2 seconds.]
drive [forward v] for (200) [mm v] ▶