View Single Post
  #3   Spotlight this post!  
Unread 09-03-2007, 07:46
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,515
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: autonomous timing

Do not use while loops.

Remember, the code loops already. Simply increment the counter each loop and have an if / then statement to do whatever when it reaches the loop count that you want.

count++;
if (count <= 10)
{
pwm01=200;
pwm02=254;
}
else if ((count >=10) && (count <= 50))
{
pwm01=254;
pwm02=254;
}

Technically speaking you don't need the count >= 10 in else if because it won't make it there if the count IS less than 10 - it will do the first if then kick out. But I have the guys I work with do it that way for clarity's sake.