View Single Post
  #3   Spotlight this post!  
Unread 06-12-2004, 21:57
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: Please Help: Programming the Robovation Kit

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
}
__________________
http://www.mikesorrenti.com/