timers

The NXT has three built-in timers that act like stopwatches. You can use a timer to tell you how long your program has been running or to measure how long it takes the robot to perform a particular task. Typically using a timer is a two-step process: You reset the timer to 0 before beginning a task, and then read the timer when the task is complete. Think of a timer as a kind of sensor for time.

Like a stopwatch, a timer can be used for a variety of purposes. For example, you can do any of the following:

  • Time how long it takes your entire program to run and use that information to fine-tune parts of your program. For example, you might measure how long it takes your robot to solve a maze and then use that information to find the fastest solution. ...

Get The Art of LEGO MINDSTORMS NXT-G Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.