Using the Timer

The Timer can be used to measure time intervals. The Timer is used like a sensor, but it is internal to the EV3 Brick and does not require a sensor port. You could use the Timer to measure, for example, how long it takes your robot to move a certain distance.

The EV3 has eight timers, so you can time up to eight different things together. You can reset a timer to zero at any point in your program, and it will start timing from that point.
Tips and Tricks
If you simply want to wait for a certain amount of time in your program, you can use the Wait block in the Wait Time mode. Using the Timer lets you reset the timer and test the timer at different places in your program.
Timer Data
The Timer gives the following data:
DataTypeNotes
Elapsed Time NumericElapsed time since the timer was last reset, in seconds.
Tips and Tricks
Tip: Time is measured in seconds using a decimal number. An interval of one tenth of a second would result in an Elapsed Time of 0.1 seconds.
Resetting a Timer
You can reset a timer to zero (0.0 seconds) at any point in your program by using the Timer block in Reset mode. After a timer is reset, it starts timing again immediately from zero. All eight timers are automatically reset at the beginning of a program and are always running.
Tips and Tricks
If you measure a timer that has never been reset, you will get the elapsed time since the program started.
Examples Using the Timer
Examples of how you can use the Timer in your program are shown below.
Example 1: Make a Motor Move Once every Second
This program makes a motor turn 45 degrees exactly once every second, like a ticking clock. The program uses the Medium Motor block to turn the motor by 45 degrees, which will take a bit of time, but less than 1 second. Then the program needs to wait for the remainder of the 1-second interval to end before moving the motor again. To do this, the program starts timer 1 before starting the motor by using the Timer block in Reset mode. Then after the motor stops, a Wait block in Timer – Compare - Time mode waits for timer 1 to reach 1 second. This will make the total interval 1 second, including both the time the motor is moving and the time it is stopped.
Example 2: Measure How Long a Touch Sensor is Held in
This program measures how long the touch sensor is held in each time it is pressed, and the result in seconds is displayed on the EV3 Display. The program uses the Wait block to wait for a touch sensor press and then again to wait for the release. After the press, timer 1 is reset using the Timer block in Reset mode. After the release, the elapsed time for timer 1 is measured using the Timer block in Measure – Time mode. The resulting number is wired to a Display block to display the number in seconds.
Timer Blocks and Modes
The table below shows all of the programming blocks and modes that you can use with Timer.
BlockModeUse
Wait Timer - Compare – TimeWait for a timer to reach a certain value.
WaitTimer – Change - TimeWait for a timer to change by a certain amount.
Loop TimerRepeat a sequence of blocks until a timer reaches a certain value.
Switch TimerChoose between two sequences of blocks based on a timer.
TimerMeasureRead a timer, and get the result in seconds on a Numeric data wire.
TimerCompareCompare a timer to a threshold, and get the result on a Logic data wire.
TimerResetReset a timer to zero. The timer starts timing again immediately.
Tips and Tricks
Simple uses of timers may also be able to use the following blocks and modes:
BlockModeUse
WaitTime IndicatorWait for a certain amount of time.
LoopTime IndicatorRepeat a sequence of blocks for a certain amount of time.
Timer
Quick links