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.