Thread: sleep()
View Single Post
  #11   Spotlight this post!  
Unread 22-02-2004, 14:51
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: sleep()

Quote:
Originally Posted by ChrisA
There's something called a "FOR LOOP". In this loop, you can specify how long it stays in the loop. You could increment a variable there if you wanted to 'wait' for a certain amount of time. Or, you could use what we like to call a "TIMER". Timers count time. Time can be used for waiting.

Maybe you should be a little more specific on what you're trying to do.
If you care, the struture of the for loop is this:
Code:
for(initiazation; test; increment)
{
    // body of loop
}
It is more flexible than that form indicates, but that would be the most common way to use it. A quick example of it actually being used as a "pause."
Code:
// Somewhere at the top
unsigned int i;

// Later on
for(i = 0; i < 10; i++)
{
    // Do nothing
}
This code would cause it to loop ten times and then continue.

Note that if you were using this as a timer, it would be different at different battery charges as the controller would run slower.

Anyways, if anyone cares, there it is.
__________________