Programming Autonomous mode

How do you program Autonomous mode on the new controllers? I just figured I would go into the main.c file and fix it up the way I wanted it. The comments say not to edit this though, so any help on where to call the functions I write for Autonomous mode would be appreciated. In addition, how do you stop the joystick from getting input?

In the user_functions.c there’s a part that says “INSERT YOUR OWN CODE HERE” (or something to that effect). I’m assuming that’s where you insert your own code :wink:

On the other question, I believe the Programming Guide says there’s no way to switch between autonomous and user modes on the EDU-Controller. (I might be wrong on that one) But you COULD make some auto. code and then upload diff code to practice driving… :slight_smile:

From what I gather the only files, or whatever they are called, that you should change are the user_routines and the user_routines_fast. The other ones shouldn’t be changed.

I would just connect a switch to one of the digital inputs and use that to control when the bot is in “autonomous” mode vs. driver-controlled mode.

Then just use an “if” statement:

if (rc_dig_in16) {
  // Run Autonomous Code
} else {
  // Run Driver Control Code

You could put this in the Process_Data_From_Master_uP() function found in user_routines.c. If you want to keep the default drive code, put it after the call to Default_Routine(), however you could nix the default drive code by replacing that call with your new code.