Issues with programming pneumatics

Hello!

We are requesting help with getting our pneumatics running in driver control (we recently switched over to visual studio code). Here is the code:

// mobile goal clamp
  if(controller(primary).ButtonY.pressing() && GOALCLAMP == 0){
    GOALCLAMP = 1;
    if(MOBILEGOAL1.value()){
      MOBILEGOAL1.set(false);
      MOBILEGOAL2.set(false);
    }
    else{
      MOBILEGOAL1.set(true);
      MOBILEGOAL2.set(true);
    }
  }else if(controller(primary).ButtonY.pressing() == false && GOALCLAMP == 1){
    GOALCLAMP = 0;
  }
}

//Test Clamp

//Doink code
if(controller(primary).ButtonRight.pressing() && LDOINK == 0){
LDOINK = 1;
if(LEFTDOINK.value()){
LEFTDOINK.set(false);
}
else{
  LEFTDOINK.set(true);
}
}
//else if(controller(primary).ButtonRight.pressing() == false && LDOINK == 1){
  //LDOINK = 0;
//}

//if(controller(primary).ButtonY.pressing() && RDOINK == 0){
  //RDOINK = 1;
 // if(RIGHTDOINK.value()){
 //   RIGHTDOINK.set(false);
 // }else{
  //  RIGHTDOINK.set(true);
 // }
//}else if(controller(primary).ButtonY.pressing() == false && RDOINK == 1){
  //RDOINK = 0;
//}

//Arm code
if(controller(primary).ButtonL1.pressing() && ARM == 0){
    ARM = 1;
    if(LEFTARM.value()){
      LEFTARM.set(false);
      RIGHTARM.set(false);
    }
    else{
      LEFTARM.set(true);
      RIGHTARM.set(true);
    }
  }else if(controller(primary).ButtonL1.pressing() == false && ARM == 1){
    ARM = 0;
  }
}

Can anyone tell us what we may have done wrong? Thank you!

edit: code tags added by mods, please remember to use them (block quote generally does not work for code)

The code below might be easier and a bit more reliable with fewer lines.

// Begin project code
bool GoalAirState = false; //This is your variable to remember in/out

void ChangeGoalAirState(){
  GoalAirState = !GoalAirState;  //Flips the variable
  MobileGoalAct1.set(GoalAirState); //Sets the actuator to the variable
}

Below in the main add the ButtonY.pressed (not pressing) to call the ChangeGoal function above.

  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(userControl);
  Controller1.ButtonY.pressed(ChangeGoalAirState);  //Add this line
2 Likes

Thank you! Trying this today.