Timer#
Introduction#
The VEX IQ (1st gen)’s Brain has a timer that 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.
重置计时器
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
当开始
[Display the time the robot takes to turn right.]
驱动 [向前 v] (200) [毫米 v] ▶
重置计时器
[右 v] 转 (90) 度 ▶
将打印精度设置为 [0.1 v] 到 [Brain v]
在 [Brain v] 上打印 [Turn right took] ◀ 并设定光标为下一行
在 [Brain v] ▶上打印 (计时器秒数)
在 [Brain v] ▶上打印 [ seconds]
timer in seconds#
The timer in seconds block returns the elapsed time since the timer was last reset, as a float in seconds.
(计时器秒数)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
当开始
[Display the time it takes to move in a square.]
重复 (4)
驱动 [向前 v] (100) [毫米 v] ▶
[右 v] 转 (90) 度 ▶
结束
将打印精度设置为 [0.01 v] 到 [Brain v]
在 [Brain v] ▶上打印 (计时器秒数)
when timer#
The when timer block activates the attached stack of blocks after a specified amount of time.
当计时器> [1] 秒
Parameters |
Description |
|---|---|
time |
Specifies the number of seconds before the attached stack of blocks starts. Accepts both whole and decimal numbers. |
Example
当计时器> [2] 秒
[Play a sound after 2 seconds.]
播放声音 [闹钟 v]