Quote:
|
Originally Posted by CharlieWilken
We need help with code in autonomous. We want our robot to turn (left or right) stop and then actuate a relay and move a speed controller motor. We need to know how to make the code and where to put it in the default code.
Thanks team 634
|
Look in the file user_routines_fast.c and look for User_Autonomous_Code(). You will put your code here. I suggest implementing a simple state machine, e.g.:
Code:
switch (auton_state) {
case TURN:
{
// put code to turn in desired direction here
// change state when you are done turning
// you'll know this either by a pre-determined time,
// a gyro reading/accumulation, or an encoder system
break;
}
case ACTUATE:
{
// put code here to actuate the relay/move motor
break;
}
...
default:
{ // either you have a default condition, or this should print an error
}
}
You can add as many states as suits your pleasure -- this makes it easy to change how you do the auton mode quickly. Make sure you change the state to the next one once you are done with the current. A little more details/more info on what you want/your robot would help to elicit a more specific response ... but this should get you started.