Project 09 – Remote Control

Lesson Attachments

Some information about timers

VEX V5 only has one built-in timer (Brain.Timer).  Follow this link for extensive information on how to manage that timer.

Simple timer control looks like this:

Brain.Timer.reset();  //resets the internal timer to 0.
while (Brain.Timer.value() < 60) {    //performs some action in a loop while timer is <60 seconds.

To display the current time based on the previous commands:

Brain.Screen.print(“Time Remaining: %2.0f”, 60 – Brain.Timer.value());

But I need multiple timers!

If you require more than one timer, you can create variables and set them to the current Brain.Timer value at the beginning of your timed action.  At the completion of your timed action, you can deduct the current value of the variable from the total Brain.Timer value and set that equal to your variable.  This will give you the net time elapsed.  You can create any number of variables to represent as many “timers” as you need.

Brain.Timer.reset();
startTimeA = Brain.Timer.value();
//something happens
double currentTimeA = Brain.Timer.value() – startTimeA;
//Result is the net time difference!

Note: You may not be familiar with the variable type known as “double”.  Put simply, it is a type of float variable capable of storing twice (double) the number of bits as a float.

Floating point type Memory requirement Range
Float 4 bytes ±3.40282347E+38F i.e. 6-7 significant digits
Double 8 bytes ±1.79769313486231570E+308 i.e. 15-16 significant digits