Ascend
Coding
Ascend
  • 🚀Introduction
  • VEX Robotics
    • 🛠️Building
      • 📏CAD Design
      • 🔧Best Practices
      • 🏎️Drive Trains
        • 🔩Screw Joints
        • 🥊Boxing
        • 🔵Bearing flats
        • 🛤️Fixing Friction
        • 🔥450 RPM on 2.75"
      • 🏍️Motors
      • 🪨Metal
      • Plastic
      • 🎈Pneumatics
      • ➕Additional Mechanisms
        • 🖨️3D Printing
        • ↔️Ratchets
        • 🏹Catapults
        • 🎣Intakes
        • 🏋️Lifts
    • 💻Coding
      • ⚖️Choosing Your Coding Environment
      • 🔴VEXCode Pro
        • 🖥️Getting Started
        • 🚗Drive Code
        • 🚴Coding Motors
        • 🌬️Coding Pneumatics
        • 🎛️Advanced
          • 📡Coding Autonomous
          • 📈Coding PIDs
            • ⬆️Drive PID Tutorial
            • ↩️Turn PID Tutorial
            • 🎸Tuning PIDs
              • 🔢Ziegler-Nichols Method
              • 📊Graphing PIDs
          • 📋Tasks
          • 🚝Advanced Drive Code
      • 🟡PROS
    • 📗Engineering Notebook
      • 📔Formatting
      • ⭐Notebook Walkthrough
      • 💠Decision Matrices
        • 📌Decision Point
      • ➕Additional Resources
    • 🏆Tournaments
      • 🗣️Team Interviews
        • 🪙Interview Tips
        • ⛳Interview Scoring
        • 🤽‍♀️Interview Practice Questions
      • 🤹Skills
      • ℹ️Ranking and Stats
      • 📷Filming Matches
  • Other
    • 🧑‍💼Management
      • 🕑Time Management
      • 👨‍👩‍👧‍👦Team Management
        • 👮Delegation
        • ⚓Optimal Team Size
      • 🖇️Code Management (GitHub)
      • 🚋Resource Management
      • ⁉️Stuck?
    • 🍎Physics
      • ⚙️Torque
      • 😑Stress Forces
    • 👾Extra stuff
      • 📸96504 Gallery
      • ⛑️VEX Team Resources (High Stakes)
      • 🏎️Driving Simulator
Powered by GitBook
On this page

Was this helpful?

  1. VEX Robotics
  2. Coding
  3. VEXCode Pro
  4. Advanced

Coding Autonomous

12.5% of the match

The Autonomous period is only 15 seconds, but it can make a huge difference in matches. In this section, we'll show you how to set up code to run during autonomous.

Before we can make the autonomous program, we have to set up the code to interface with the field controllers. That is, when the controller is told to run autonomous during a match, your code needs to recognize that and call the right function. Thus, we'll initialize a Competition variable at the beginning of the main file, after the using namespace vex; line.

competition Competition;

Next, we'll make a function called autonomousProgram(). This function will contain all of the code that your autonomous will run.

void autonomousProgram(void) {    
    //insert autonomous code here
}

Now, we need to tell the controller that we want this function to run when autonomous starts. To do that, we need to add the line Competition.autonomous(autonomousProgram); immediately after the vexcodeInit() line.

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Set up callback for the autonomous period
  Competition.autonomous(autonomousProgram);

  //you may have more code below, leave it there
}

Now, you can simply put whatever code you would like to run during autonomous in the autonomousProgram() function, and it will run. If you want to have multiple options for autonomous, you can create multiple programs.

PreviousAdvancedNextCoding PIDs

Last updated 10 months ago

Was this helpful?

💻
🔴
🎛️
📡