V5 coding help (int main error)

I am brand new to vex code and I am trying to program my lift I keep getting this error I was wondering if anyone could help me?36%20AM

please share your entire code in dropdown image and in code wraps

@Logan10622D's Code

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

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Drivetrain drivetrain 20, 11
// Controller1 controller
// ---- END VEXCODE CONFIGURED DEVICES ----

#include “vex.h”

using namespace vex;

// A global instance of competition
competition Competition;
// defining motors
// define your global instances of motors and other devices here
vex::motor Left(vex::PORT11, vex::gearSetting::ratio18_1,true);
vex::motor Right(vex::PORT20, vex::gearSetting::ratio18_1,false);
vex::motor LeftLift(vex::PORT1, vex::gearSetting::ratio36_1,true);
vex::motor RightLift(vex::PORT10, vex::gearSetting::ratio36_1,false);
vex::motor SecondLift(vex::PORT13, vex::gearSetting::ratio36_1,false);
vex::motor LeftClaw(vex::PORT2, vex::gearSetting::ratio18_1,true);
vex::motor RightClaw(vex::PORT7, vex::gearSetting::ratio18_1,false);
vex::controller con(vex::controllerType::primary);

/ --------------------------------------------------------------------------- /
/* 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) {
Left.spin(reverse);
Right.spin(reverse);
LeftLift.spin(reverse);
RightLift.spin(reverse);
wait(1, sec);
LeftClaw.spin(forward);
RightClaw.spin(forward);
wait(4, sec);
LeftClaw.stop();
RightClaw.stop();
wait(5, sec);
Left.spin(forward);
Right.spin(forward);
wait(2, sec);
LeftLift.stop();
RightLift.stop();
Left.stop();
Right.stop();
}

/ --------------------------------------------------------------------------- /
/* /
/
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) {
int LeftLiftSpeedPCT = 90;
int RightLiftSpeedPCT = 90;
int LeftClawSpeedPCT = 100;
int RightClawSpeedPCT = 100;

// User control code here, inside the loop
///Button Y up pri lift
while (1) {
if(con.ButtonY.pressing()) {
RightLift.spin(directionType::rev, RightClawSpeedPCT, velocityUnits::pct);
}
else if (con.ButtonY.pressing()) {
RightLift.spin(directionType::fwd, RightClawSpeedPCT, velocityUnits::pct);
}
else{
RightLift.stop(brakeType::brake);
}
if(con.ButtonY.pressing()) {
LeftLift.spin(directionType::rev, LeftClawSpeedPCT, velocityUnits::pct);
}
else if (con.ButtonY.pressing()) {
LeftLift.spin(directionType::fwd, LeftClawSpeedPCT, velocityUnits::pct);
}
else{
LeftLift.stop(brakeType::brake);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
while (1) {
if(con.ButtonRight.pressing()) {
RightLift.spin(directionType::fwd, RightClawSpeedPCT, velocityUnits::pct);
}
else if (con.ButtonRight.pressing()) {
RightLift.spin(directionType::rev, RightClawSpeedPCT, velocityUnits::pct);
}
else{
RightLift.stop(brakeType::brake);
}
if(con.ButtonRight.pressing()) {
LeftLift.spin(directionType::fwd, LeftClawSpeedPCT, velocityUnits::pct);
}
else if (con.ButtonRight.pressing()) {
LeftLift.spin(directionType::rev, LeftClawSpeedPCT, velocityUnits::pct);
}
else{
LeftLift.stop(brakeType::brake);
}
//////////////
if(con.ButtonL1.pressing()) {
SecondLift.spin(directionType::fwd, LeftLiftSpeedPCT, velocityUnits::pct);
}
else if (con.ButtonL2.pressing()) {
SecondLift.spin(directionType::fwd, LeftLiftSpeedPCT, velocityUnits::pct);
}
else{
SecondLift.stop(brakeType::brake);
}
if(con.ButtonR1.pressing()) {
RightClaw.spin(directionType::rev, RightClawSpeedPCT, velocityUnits::pct);
}
else if (con.ButtonR2.pressing()) {
RightClaw.spin(directionType::fwd, RightClawSpeedPCT, velocityUnits::pct);
}
else{
RightClaw.stop(brakeType::brake);
}
if(con.ButtonR1.pressing()) {
LeftClaw.spin(directionType::rev, LeftClawSpeedPCT, velocityUnits::pct);
}
else if (con.ButtonR2.pressing()) {
LeftClaw.spin(directionType::fwd, LeftClawSpeedPCT, velocityUnits::pct);
}
else{
LeftClaw.stop(brakeType::brake);
}

// 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]

Not sure why you have 2 while(1) loops but the first one is missing a closing bracket.

vex::task::sleep(100);

There you go.

Fix that wait(100, msec); line and you’re good to go.

That syntax doesn’t exist here.

The error is coming from a missing closing bracket not because of the wait

1 Like

The bracket is there. It can’t read it because of the error above it. Fix the wait error, the code is fixed.

If you look at the drop down code there are 28 open brackets and 27 closed brackets (Ctrl+F)

If it was because of the wait it would say wait is undefined

The wait thing also won’t work. Find the missing bracket, then also fix the wait thing.

ok thanks a lot! I wouldn’t have been able to figure this out myself

Why wouldn’t the wait thing work? He is using VexCode 1.0.1 and in VexCode 1.0.1, wait is a defined function.

It is? I haven’t used VEXcode since 0.9.