Quote:
|
Originally Posted by Dave Scheck
Max
You can try something like this to set the pwm value to 127 after 30 loops:
Code:
void pulse(void)
{
static int loop_count = 0;
if(loop_count < 30)
{
pwm06 = 254;
}
else
{
pwm06 = 127;
}
loop_count++;
}
Then, you would want to call this in your main loop. Note that this method never resets loop_count, so this would run for 30 loops at 254 and then stop.
|
As Dave said.. when you want to keep track of how many times something has looped, use a counter variable. You should try to stay away from while and for loops in your code. Even when you are in your Default Routine, you are still nested within a while loop that will execute the default routine 39 times per second.