View Single Post
  #7   Spotlight this post!  
Unread 15-02-2008, 15:51
xrabohrok's Avatar
xrabohrok xrabohrok is offline
hunter of errors
FRC #1208 (The Metool Brigade)
Team Role: Programmer
 
Join Date: Jan 2006
Location: O'Fallon
Posts: 62
xrabohrok is an unknown quantity at this point
Re: Looking for help with creating a timer.

the program loops at 36 times a second. With this knowledge, you could create something that would measure this. I wouldn't advise letting a counter variable get into the thousands, because then the program starts running slower. something like this worked nicely for me:

Code:
//global variables
int count = 0;
int second = 0;


//somewhere in code
if (count >= 37)
{
      count = 0;
}
count++;

//you could compare things like this
switch second
{
        case 0: //what happens right off the back
                  break;
        case 1: //what happens in the first second
                  break;
        case 2: //what happens in second second (ha!)
                  break;
        default: //what should happen when out of time

}
__________________
"It's programming's fault" may be a viable excuse for just about everything, except the robot falling apart.

It will 'cause it can!

constants aren't. variables won't.