View Single Post
  #3   Spotlight this post!  
Unread 19-02-2007, 20:21
SuperBK's Avatar
SuperBK SuperBK is offline
Registered User
AKA: BrianK
FRC #1225 (Amperage Robotics)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Henersonville, NC
Posts: 358
SuperBK is just really niceSuperBK is just really niceSuperBK is just really niceSuperBK is just really nice
Thumbs up Re: Programming "sleep" function

Use a counter. Its 26.2 ms for each time User_Autonomous_Code() is called.

Code:
#define STAGE_1 0   
#define STAGE_2 1
#define STAGE_3 2

inside User_Autonomous_Code()

static stage;
int counter;

state = STAGE_1;


  while (autonomous_mode)   /* DO NOT CHANGE! */
  {
switch (stage) { case STAGE_1: // turn motor on here counter = 0; stage = STAGE_2; break; case STAGE_2: ++counter; if (counter = 38) // 1 second { // turn motor off here stage = STAGE_3 } break; }
}
__________________
Brian K
Team 1225 Robotics Mentor