New to Vex, Controller help needed

I need help finding whats wrong with the code, I plan to have R1 make the lift go up and L1 make the lift go down. I’m also planning to have our left motor for driving be one stick and our our right motor for driving be the other stick.

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// leftmotor motor 1
// rightmotor motor 2
// Controller1 controller
// leftlift motor 3
// rightlift motor 8
// ---- END VEXCODE CONFIGURED DEVICES ----

#include “vex.h”

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

void usercontrol(void) {

//Lift Up
if(Controller1.ButtonR1.pressing()){
leftlift.spin(forward);
rightlift.spin(forward);
}
//Lift Down
if(Controller1.ButtonL1.pressing()){
leftlift.spin(reverse);
rightlift.spin(reverse);
}
//Joystick Forward
leftmotor.spin(forward, Controller1.Axis3.position(), pct);
rightmotor.spin(forward, Controller1.Axis2.position(), pct);

}
}

Change this

//Lift Up
if(Controller1.ButtonR1.pressing()){
leftlift.spin(forward);
rightlift.spin(forward);
}
//Lift Down
if(Controller1.ButtonL1.pressing()){
leftlift.spin(reverse);
rightlift.spin(reverse);
}

To this

    //Lift Up
    if(Controller1.ButtonR1.pressing()){
    leftlift.spin(forward);
    rightlift.spin(forward);
    }
    //Lift Down
    else if(Controller1.ButtonL1.pressing()){
    leftlift.spin(reverse);
    rightlift.spin(reverse);
    }
    else{
    leftlift.stop();
    rightlift.stop();
    }
4 Likes

I will try this later! Thank you!

Could you help me with the axis programming? Its confusing me a bit I don’t want to spam post.

Take a look at my post here:
https://www.vexforum.com/t/how-to-move-2-motors-at-the-same-time-using-a-controller/69101/3

Also I believe there’s an error as you are defining void usercontrol inside of int main

1 Like

So I should end int main before I code the controller? I thought that int main started everything, and then usercontrol was the programming of the controller, is that right?

Usercontrol is for everything during driver control, but this is only when you are using the competition template. If you aren’t using the competition template then remove ‘void usercontrol(){‘ and its corresponding brackets.

And just so you know, you can’t define a function inside of a function, so that code wouldn’t compile anyway.

1 Like

Oh okay, Thank you! I’m not using a competition template, so I’ll switch to it.