Quote:
|
Originally Posted by krhs_programmer
hey i have a question. i am playing with the little bot in preparation for this up coming regional (if we get money  ) and i want to know how to make the bot do things using time, like run this motor for x amount of time then switch and do this. could you help me out because our programmers who knew what they were doing left last year and me and the other programmer are doing this for the first time and the only backgroung i have w/programming is from my sam's teach yourself C. i tried a few things but i had no luck. also how could i make an r\c controller to plug into the little box to control it remotely? any help w/this would be appreciated greatly. 
|
Make a counter, declare a static variable
static unsigned int intCycles = 0;
static unsigned int intSeconds = 0;
in Process_Data_From_Master_uP:
Code:
cycleCounter = cycleCounter + 1;
intSeconds = cycleCounter / 59;
Process_Data_From_Master_uP in user_routines.c is run every 17ms, so thats roughly 59 times a second. Then when you want to run something after x seconds you'd do
Code:
if(intSeconds > 5) // just an example
{
// do your code
}