|
Re: More automonous help:ending stuff
In your User_Initialization create a variable called count (you can create it anywhere but that's probably the best spot for now), with this syntax:
int count = 0;
Then at the bottom of the while(autonomous_mode) loop in your code, right above Putdata(&txdata), put in
count++;
++ in C means the same thing as "count = count + 1;", so you are incrementing it by one every time you pass through that loop. Multiply count by 40 and you have *approximately* the amount of time autonomous has been running. You'll have to time it and do the math yourself, but when you want it to break off, say something like (below your line following code):
if(count > 200){
pwm01 = 254;
pwm02 = 254;
}
else if(count > 300){
pwm01 = 0;
pwm02 = 0;
}
else if (count > 320){
pwm01 = 127;
pwm02 = 127;
}
That won't do much, just go forward and stop after a little over 2 seconds, but hopefully you get the picture on what you can do. Adjust values to your desire, and good luck.
__________________
~Alex Baxter
Programming, Arms operation, Team 254
|