Thread: Timer Question
View Single Post
  #1   Spotlight this post!  
Unread 28-03-2007, 22:22
lightning_blast lightning_blast is offline
Registered User
FRC #1814
 
Join Date: Feb 2006
Location: Canada
Posts: 15
lightning_blast is an unknown quantity at this point
Timer Question

Hi, our incredible plans to create an autonomous mode has failed (once again ) and im thinking we will have to rely on timers again. Last year, we used EasyC, but this year we're using MPLab. We have the idea of having a timer based on the number of loops. We believe each loop is 26.2 ms, so can we take this number and loop it xx times and increasing a counter each loop until it reaches the specific time?

example, we want to move 5 seconds forward
5s = 5000ms = 190 loops.

static int timer = 0;
**move forward**;
if (timer <190)
timer = timer +1 ;
if (timer >=190)
**stop**;

Thanks!!