Timer#
Introduction#
The VEX AIM Coding Robot’s timer keeps track of elapsed time from the start of a project. It can be used to measure durations, 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 – Returns the current elapsed time in seconds.
when timer – Runs a stack of blocks after the timer exceeds a specified time.
reset timer#
The reset timer block resets the timer to zero.
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.]
move [forward v] for (20) [mm v] ▶
reset timer :: custom-orientation
turn [right v] for (90) degrees ▶
print [Turn right took] on screen ◀ and set cursor to next row
print (timer in seconds) on screen ▶
print [seconds] on screen ▶
timer in seconds#
The timer in seconds block returns the elapsed time since the timer was last reset, as a float in seconds.
(timer in seconds)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Display the time after 2 seconds have passed.]
wait until < (timer in seconds) [math_greater_than_or_equal_to v] [2] >
print (timer in seconds) on screen ▶
when timer#
The when timer block activates 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
[Play a fail sound after 2 seconds.]
play sound [fail v] ▶