First Code Line Error

Hello, I am new to vex and i am having an issue with my code where regardless of what is the first line, it will show up as an error. What do I do to fix this?
image

What are you trying to achieve with all of those includes? I believe you only need to include ‘vex.h’

5 Likes

I am making a clawbot that has the new v5 motors and the older motor29 ones. would it be more easy if I posted my code?

However, each time I remove the include brain or motor stuff, it wont recognize any of the actions.

The error may be due to something further in your code, if we can see the problems tab or the compiler error that would help. I’m not suggesting removing the motor or brain declarations, but simply using the vex.h header rather than all of the individual includes

I might add that the error shown indicates something in the included file is the issue, not your code.

1 Like

Please post your entire program, remembering to wrap it in [code]...[/code] tags for formatting. Trying to debug programs we can’t see in full is difficult and time-consuming.

That said, you shouldn’t have to #include vex_motor.h, vex_brain.h, etc. - those files are all included from vex.h so #include "vex.h" should get you everything you need.

2 Likes

Here is my code, I am fairly new to this so dont be surprised to see many issues.

Main.CPP

#include “vex_motor.h”
#include “vex_brain.h”
#include “vex_motor29.h”
#include “vex_controller.h”

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// RightDrive motor 1
// LeftDrive motor 2
// Arm motor 4
// Boom motor 5
// Claw motor29 A
// Wrist motor29 C
// ---- END VEXCODE CONFIGURED DEVICES ----
using namespace vex;

brain Brain;

motor RightDrive = motor(PORT1);
motor LeftDrive = motor(PORT2, true);
motor Arm = motor(PORT4);
motor Boom = motor(PORT5);
motor29 Claw = motor29(brain.triport.A);
motor29 Wrist = motor29(brain.triport.C);
controller controller1 = controller();

int ArmSpeedPercent = 100;
int BoomSpeedPercent = 80;
int ClawSpeedPercent = 80;
int WristSpeedPercent = 80;

void usercontrol(void) {
}

int main() {
while (true) {

// Main Drive Motors
RightDrive.spin(motor.directionType::fwd, controller1.Axis2.position(),
                motor.velocityUnits::pct);
LeftDrive.spin(motor.directionType::fwd, controller1.Axis3.position(),
               motor.velocityUnits::pct);

// Arm Motors
if (controller1.ButtonR1.pressing()) {
  Arm.spin(motor.directionType::fwd, ArmSpeedPercent,
           motor.velocityUnits::pct);
} else if (controller1.ButtonL1.pressing()) {
  Arm.spin(motor.directionType::rev, ArmSpeedPercent,
           motor.velocityUnits::pct);
} else {
  Arm.stop(motor.brakeType::brake)
}

// Boom Motors
if (controller1.ButtonR2.pressing()) {
  Boom.spin(motor.directionType::fwd, BoomSpeedPercent,
            motor.velocityUnits::pct);
} else if (controller1.ButtonL2.pressing()) {
  Boom.spin(motor.directionType::rev, BoomSpeedPercent,
            motor.velocityUnits::pct);
} else {
  Boom.stop(motor.brakeType::brake)
}

// Claw Motors
if (controller1.ButtonY.pressing()) {
  Arm.spin(motor29.directionType::fwd, ClawSpeedPercent, motor29.velocityUnits::pct);
} else if (controller1.ButtonA.pressing()) {
  Arm.spin(motor.directionType::rev, ClawSpeedPercent, motor29.velocityUnits::pct);
} else {
  Arm.stop(motor.brakeType::brake);
}
// Wrist motors
if (controller1.ButtonX.pressing()) {
  Wrist.spin(motor29.directionType::fwd, ClawSpeedPercent, motor29.velocityUnits::pct);
} else if (controller1.ButtonB.pressing()) {
  Wrist.spin(motor29.directionType::rev, ClawSpeedPercent, motor.velocityUnits::pct);
} else {
  Wrist.stop(motor29.brakeType::brake);
}

//task.sleep(20);

}
}

Robot-Config.cpp

#include “vex_motor.h”

#include “vex_motor.h”

#include “vex_brain.h”

#include “vex.h”

#include “vex_controller.h”

using namespace vex;

// VEXcode device constructors

controller Controller1 = controller(primary);

motor RightDrive = motor(PORT1, ratio18_1, false);

motor LeftDrive = motor(PORT2, ratio18_1, false);

motor Arm = motor(PORT4, ratio36_1, false);

motor Boom = motor(PORT5, ratio36_1, false);

motor29 Claw = motor29(brain.ThreeWirePort.A, false);

motor29 Wrist = motor29(brain.ThreeWirePort.C, false);

// VEXcode generated functions

// define variable for remote controller enable/disable

bool RemoteControlCodeEnabled = true;

/**

  • Used to initialize code/tasks/devices added using tools in VEXcode Text.

  • This should be called at the start of your int main function.

*/

void vexcodeInit( void ) {

}