View Single Post
  #3   Spotlight this post!  
Unread 21-02-2005, 22:10
ConKbot of Doom ConKbot of Doom is offline
Team Alumni
FRC #1184 (Cobra Robotics)
Team Role: Leadership
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Maryland
Posts: 153
ConKbot of Doom has a spectacular aura aboutConKbot of Doom has a spectacular aura aboutConKbot of Doom has a spectacular aura about
Re: Simple Autonomous Code

I don't have any example code, but you could use the fact that the code is executed once every 26.2 milliseconds and use some decrementing (or incrementing) counters and some if statements...

well, sort of an example, but definitely needs refinement
Code:
count = count + 1;
if (count = 15)
  {
  pwm01 = 180;
  pwm02 = 180;
  }
if (count = 45)
  {
  pwm01 = 255;
  pwm02 = 0;
  }
If I have the idea correct, as count reaches 15, the bot will go forward at a medium speed, then when it reaches 45, it will turn, one side full speed forward, one side full speed back. You get the idea? Just remember that every "count" is 1/38 of a second.

EDIT: got beaten to it... oh well I'll leave it there for the code