Need help with this code

ok… so… the 2 picker motors are not running on the robot. can you help?

while (1){
    Left.spin(vex::directionType::rev, Controller1.Axis2.value(), vex::velocityUnits::pct);
    Right.spin(vex::directionType::fwd, Controller1.Axis3.value(),vex::velocityUnits::pct);
    BackLeft.spin(vex::directionType::rev, Controller1.Axis2.value(),vex::velocityUnits::pct);
    BackRight.spin(directionType::fwd, Controller1.Axis3.value(),vex::velocityUnits::pct);    
        Picker.spin(vex::directionType::fwd,50, vex::velocityUnits::pct);
        ClawTighten.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct);
    else if(Controller1.ButtonR1.pressing())
        Picker.spin(vex::directionType::rev,50, vex::velocityUnits::pct);
        ClawTighten.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);

        Lifter1.spin(vex::directionType::fwd,75, vex::velocityUnits::pct);
        Lifter2.spin(vex::directionType::fwd,75, vex::velocityUnits::pct);
    else if(Controller1.ButtonL2.pressing())
        Lifter1.spin(vex::directionType::rev,90, vex::velocityUnits::pct);
        Lifter2.spin(vex::directionType::rev,90, vex::velocityUnits::pct);

First off, your gonna want to reclassify this as VexCode support, Vex Coding Studio has been discontinued. Second off, try to see if your motors are plugged into the correct ports. Last of all, out of curiosity, what is a picker?

picker is one of the motors that is working. I did not name it. Motors are plugged in correctly

I thought you said that the picker motors weren’t running?

sorry, the lifters arent working

The “Lifter” motors are the only motors not working? As in, all of your other motors work, including the picker/clawtighten motors?

You seem to have an extra curly-bracket-thingy before your if statement for your lifters. Did vexcode give you an error? Because I don’t see match for it.


nice catch …hhhhhhh

yes, they do work, other than the lifter motors

The bracket is not resulting in an error message, as it just compiles.

Is this your entire code or just a section of it then?

it’s a section of it

Then is the curly bracket matched up with some other part of your code then?

The code may be able to compile, but it doesn’t mean it’ll work. You need to move one of your extra curly brackets to the end. Right now the Lifter motors are outside the while loop so it will never run.

This is how your code is setup

//Stuff that actually runs
//Lifter Motor stuff

As you can see, the lifter motor stuff in your code is outside the while loop, so it will never move the lifter


Thank you! You’re a lifesaver as our tournament is this week

1 Like