计时器#
简介#
The VEX AIM Coding Robot’s timer 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.
以下是所有模块的列表:
重置计时器 — 将计时器重置为零。
timer in seconds — Reports how much time has passed.
当定时器 — 在定时器超过指定时间后运行一个代码块栈。
重置计时器#
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
参数 |
描述 |
|---|---|
该指令块没有参数。 |
示例
when started
[Display the time the robot takes to turn right.]
move [forward v] for (20) [mm v] ▶
reset timer
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 ▶
计时器(以秒为单位)#
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)
参数 |
描述 |
|---|---|
该指令块没有参数。 |
示例
when started
[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 ▶
当计时器#
The when timer hat block runs the attached stack of blocks after a specified amount of time.
when timer > [1] seconds
参数 |
描述 |
|---|---|
时间 |
设定其所连指令段启动前需等待的秒数。可接受整数和小数。 |
示例
when timer > [2] seconds
[Play a fail sound after 2 seconds.]
play sound [fail v] ▶