I need help with fixing my code

Gosh, it feels like every night I post here on this forum…

We have a issue with our driver code. when we bring our arm motors up with b, they go up just fine. however, when we try to bring them back down with A, they do not do so. Here’s the code:

if(Controller1.ButtonB.pressing())
RightArm.spin(vex::directionType::rev);
else
RightArm.stop();
if(Controller1.ButtonB.pressing())
LeftArm.spin(vex::directionType::rev);
else
LeftArm.stop();
if(Controller1.ButtonA.pressing())
LeftArm.spin(vex::directionType::fwd);
else
LeftArm.stop();
if(Controller1.ButtonA.pressing())
RightArm.spin(vex::directionType::fwd);
else
RightArm.stop();

try

if(Controller1.ButtonB.pressing()) {
RightArm.spin(vex::directionType::rev);
LeftArm.spin(vex::directionType::rev);
}
else if(Controller1.ButtonA.pressing()) {
LeftArm.spin(vex::directionType::fwd);
RightArm.spin(vex::directionType::fwd);
}
else {
RightArm.stop();
LeftArm.stop();
}
1 Like

Ok, now i’m getting an “expected expression error” on the else part.

Change to

if(Controller1.ButtonB.pressing()) {
RightArm.spin(vex::directionType::rev);
LeftArm.spin(vex::directionType::rev);
}
else if(Controller1.ButtonA.pressing()) {
LeftArm.spin(vex::directionType::fwd);
RightArm.spin(vex::directionType::fwd);
}
else {
RightArm.stop();
LeftArm.stop();
}

I swapped a parenthesis with a curly brace.

3 Likes

thank you! you’re a lifesaver

nice catch …20char

1 Like

hope its not too much of a bother, but, can you change the power of the motors?

LeftArm.setVelocity(50, velocityUnits::pct);
1 Like