Quote:
|
Originally Posted by Zaramel2002
I was wondering how to make the program below count the encoder then go to another step instead of ending.
Im trying to make this code my encoder program for this years robot please help.
|
I use a static and a loop (in this case, Count is incremented by the sub, but is easily modifiable for ticks)
Code:
void Auto(void)
{
static long Count = 0;
if (Count >= 100) //Example, highest first
{
//Step 5
count=0
}
else if (Count >= 80) //Example
{
//Step 4
}
else if (Count >= 60) //Example
{
//Step 3
}
else if (Count >= 40) //Example
{
//Step 2
}
else if (Count >= 20) //Example
{
//Step 1
}
Count = Count + 1;
} //End Auto()