VexCode Project Closed with Exit Code 2 help!

Screenshot (29)

Help! it says exit code 2, but I don’t exactly know what that means, and there are no errors shown in my code. I have tried reading other topics, but I can’t seem to understand any of the solutions.

[code} /
/----------------------------------------------------------------------------/
/* /
/
Module: main.cpp /
/
Author: VEX /
/
Created: Thu Sep 26 2019 /
/
Description: Competition Template /
/
/
/
----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----

// ---- END VEXCODE CONFIGURED DEVICES ----

#include “vex.h”

using namespace vex;
vex::brain Brain;
vex::controller Controller;
vex::motor BackRight(vex::PORT1, vex::gearSetting::ratio18_1, true);
vex::motor FrontRight(vex::PORT2, vex::gearSetting::ratio18_1, false);
vex::motor BackLeft(vex::PORT3, vex::gearSetting::ratio18_1, true);
vex::motor FrontLeft(vex::PORT4, vex::gearSetting::ratio18_1, false);
// A global instance of competition
competition Competition;

// define your global instances of motors and other devices here

/---------------------------------------------------------------------------/
/* Pre-Autonomous Functions /
/
/
/
You may want to perform some actions before the competition starts. /
/
Do them in the following function. You must return from this function /
/
or the autonomous and usercontrol tasks will not be started. This /
/
function is only called once after the V5 has been powered on and /
/
not every time that the robot is disabled. /
/
---------------------------------------------------------------------------*/

void pre_auton(void) {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();

// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, …
}

/---------------------------------------------------------------------------/
/* /
/
Autonomous Task /
/
/
/
This task is used to control your robot during the autonomous phase of /
/
a VEX Competition. /
/
/
/
You must modify the code to add your own robot specific commands here. /
/
---------------------------------------------------------------------------*/

void autonomous(void) {
// …
// Insert autonomous user code here.
// …
}

/---------------------------------------------------------------------------/
/* /
/
User Control Task /
/
/
/
This task is used to control your robot during the user control phase of /
/
a VEX Competition. /
/
/
/
You must modify the code to add your own robot specific commands here. /
/
---------------------------------------------------------------------------*/

void usercontrol(void) {
// User control code here, inside the loop
while (1) {
BackRight.spin(directionType::fwd, Controller.Axis2.value(), velocityUnits::pct);
FrontRight.spin(directionType::fwd, Controller.Axis2.value(), velocityUnits::pct);
BackLeft.spin(directionType::fwd, Controller.Axis3.value(), velocityUnits::pct);
FrontLeft.spin(directionType::fwd, Controller.Axis3.value(), velocityUnits::pct);
// This is the main execution loop for the user control program.
// Each time through the loop your program should update motor + servo
// values based on feedback from the joysticks.

// ........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
// ........................................................................

wait(20, msec); // Sleep the task for a short amount of time to
                // prevent wasted resources.

}
}

//
// Main will set up the competition functions and callbacks.
//
int main() {
// Set up callbacks for autonomous and driver control periods.
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);

// Run the pre-autonomous function.
pre_auton();

// Prevent main from exiting with an infinite loop.
while (true) {
wait(100, msec);

}
}
[/code]

It looks like you are defining the brain more than twice. Double check your robot config to see if it is defined twice.

3 Likes

I had the same problem and apparently it was a file conflict, check if this is in the folder where the project is saved, if in the folder where your project is saved there is more than one “.v5code” file, delete the rest and just leave the original