Solenoid only stays on true mode and is not reacting to other buttons

void usercontrol(void) {

//vex::thread n(pusher);

enableDrivePID = false;

// User control code here, inside the loop

while (1) {

float input_h = Controller1.Axis1.value()/12.0;

float input_v = Controller1.Axis2.value()/12.0;

float maxVolt = 12;

float deadzone = 6;

//0>127

//deadzone

input_h = input_h*(std::abs(input_h) >= deadzone);

input_v = input_v*(std::abs(input_v) >= deadzone);

RightFrntmotor.spin(vex::directionType::rev,(input_h + input_v)*maxVolt, vex::voltageUnits::volt);

RightBckmotor.spin(vex::directionType::rev, (input_h + input_v)*maxVolt, vex::voltageUnits::volt);

LeftFrntmotor.spin(vex::directionType::fwd, (input_h - input_v)*maxVolt, vex::voltageUnits::volt);

LeftBckmotor.spin(vex::directionType::fwd, (input_h - input_v)*maxVolt, vex::voltageUnits::volt);

CallOfDuty.spin(vex::directionType::fwd, -Controller1.ButtonR2.pressing()*12, vex::voltageUnits::volt);

CallOfDuty2.spin(vex::directionType::fwd, -Controller1.ButtonR2.pressing()*12, vex::voltageUnits::volt);

if( Controller1.ButtonL2.pressing() ){

solenoid.set( true );

}if( Controller1.ButtonL1.pressing()){

solenoid.set( false );

wait(20,msec);

}

Can you please add code tags (```) before and after your code in the post.
Add a closing bracket in-between the solenoid.set(false) and the wait(20,msec) and also add an additional closing bracket after the wait(20,msec)

2 Likes

Try an else or else if statement