Quote:
|
Originally Posted by Kevin Watson
What happens when counter == 240? I think you should be using a >= or <= in there someplace.
|
I was going to say "IN THIS CASE, I doubt that it would cause a problem." (Because I expected that the RC would just continue doing what had been doing for 1/40th of a second longer.) But then I looked at the "else" case, and saw that it would set the end_program flag, terminating the autonomous program.
I would prefer to fix this by doing something less error-prone like this:
Code:
if(counter < 121) /* if less than 2 seconds have passed */
{...}
else if(counter < 240) /* if 2-4 seconds have passed */
{...}
else if(counter < 360) /* if 4-6 seconds have passed */
{...}
else if(counter < 480) /* if 6-8 seconds have passed */
{...}
else if(counter < 600) /* if 8-10 seconds have passed */
{...}
else if(counter < 720) /* if 10-12 seconds have passed */
{...}
else if(counter < 780) /* if 12-13 seconds have passed */
{...}
else if(counter < 900) /* if 13-15 seconds have passed */
{...}
else /* if more than 15 seconds have passed */
{...}
}
Quote:
|
(This bug bites me all the time <grin>).
|
Yeah, it's gotten me a few times too.
