Up and Down buttons not working?

Hey besties, I’m having trouble with the Up and Down buttons on our controller and we’re not sure if it’s the program or controllers fault. The program says it has no errors but when pressing the buttons, nothing happens. Our L & R buttons work fine. When using the “uwu” or “owo” statements, it claims that we never defined it. Any suggestions?

    void usercontrol(void) {
  // User control code here, inside the loop
  
  while (1) {
    
     
    double rightSpeed = Controller1.Axis2.position(percent);
    double leftSpeed = Controller1.Axis3.position(percent);

    double leftDriveVolts = leftSpeed * 0.8;
    double rightDriveVolts= rightSpeed * 0.8;
    
    rightwheel.spin(forward,rightDriveVolts,percent);
    leftwheel.spin(forward,leftDriveVolts,percent);
    
   if (fabs(Controller1.Axis2.position(percent)) > 20) {
      rightwheel.spin(forward,rightDriveVolts,percent);
   }
      else { 
      rightwheel.spin(forward,0.0,percent);
    }

    if (fabs(Controller1.Axis3.position(percent)) > 20){
      leftwheel.spin(forward, Controller1.Axis3.position(percent), percent);
    } 
    else {
      leftwheel.spin(forward,0.0,percent);
    }
    
    bool Right1 = Controller1.ButtonR1.pressing();
    bool Right2 = Controller1.ButtonR2.pressing();
    bool Left1 = Controller1.ButtonL1.pressing();
    bool Left2 = Controller1.ButtonL2.pressing();
    bool uwu = Controller1.ButtonDown.pressing();
    bool owo = Controller1.ButtonUp.pressing();
    

  if (Right1) {
      lift1.spin(forward, 8, vex::voltageUnits::volt);
      lift2.spin(forward, 8, vex::voltageUnits::volt);
      lift3.spin(forward,7,vex::voltageUnits::volt);
    } else if (Right2) {
      lift1.spin(reverse, 8, vex::voltageUnits::volt);
      lift2.spin(reverse, 8, vex::voltageUnits::volt);
      lift3.spin(reverse,7,vex::voltageUnits::volt);
    
    } else {
      lift1.stop();
      lift2.stop();
      lift3.stop();
    }
    
    if (Left1){
    middlespin.spin(forward,4,vex::voltageUnits::volt);
    } else if (Left2){
      middlespin.spin(reverse,4,vex::voltageUnits::volt);
    } else
    { middlespin.stop();}
    }

    if (Controller1.ButtonDown.pressing()) {
    lift3.spin(forward,7,vex::voltageUnits::volt);
    }
    else if (Controller1.ButtonUp.pressing()) {
    lift3.spin(reverse,7,vex::voltageUnits::volt);
  } else 
  {lift3.stop(); }

    
}

I am no expert, but you may want to check the controller and see if is labeled the same as it is in the code. Im not entirely sure, I am just suggesting. Try changing the uwu and owo to up and down.

1 Like

First, I would like to apologize for earlier. It was a rough day for me. Second, I agree with SirBob. Try changing the uwu and owo to up and down. Third, this is just a suggestion, but try making the else if at the bottom into just an if statement. It may or may not work, I’m just trying to help.

3 Likes

Good formatting of code is really important, it helps find errors far more easily
code like this make’s it hard to follow where all the braces have been placed and if they match correctly.

    if (Controller1.ButtonDown.pressing()) {
    lift3.spin(forward,7,vex::voltageUnits::volt);
    }
    else if (Controller1.ButtonUp.pressing()) {
    lift3.spin(reverse,7,vex::voltageUnits::volt);
  } else 
  {lift3.stop(); }

So I reformatted your code (and added a couple of comments), you can now easily see the issue.

void usercontrol(void) {
  // User control code here, inside the loop
  
  while (1) {
    double rightSpeed = Controller1.Axis2.position(percent);
    double leftSpeed = Controller1.Axis3.position(percent);

    double leftDriveVolts = leftSpeed * 0.8;
    double rightDriveVolts= rightSpeed * 0.8;
    
    rightwheel.spin(forward,rightDriveVolts,percent);
    leftwheel.spin(forward,leftDriveVolts,percent);
    
    if (fabs(Controller1.Axis2.position(percent)) > 20) {
      rightwheel.spin(forward,rightDriveVolts,percent);
    }
    else { 
      rightwheel.spin(forward,0.0,percent);
    }

    if (fabs(Controller1.Axis3.position(percent)) > 20) {
      leftwheel.spin(forward, Controller1.Axis3.position(percent), percent);
    } 
    else {
      leftwheel.spin(forward,0.0,percent);
    }
    
    bool Right1 = Controller1.ButtonR1.pressing();
    bool Right2 = Controller1.ButtonR2.pressing();
    bool Left1 = Controller1.ButtonL1.pressing();
    bool Left2 = Controller1.ButtonL2.pressing();
    bool uwu = Controller1.ButtonDown.pressing();
    bool owo = Controller1.ButtonUp.pressing();
    

    if (Right1) {
      lift1.spin(forward, 8, vex::voltageUnits::volt);
      lift2.spin(forward, 8, vex::voltageUnits::volt);
      lift3.spin(forward,7,vex::voltageUnits::volt);
    } 
    else if (Right2) {
      lift1.spin(reverse, 8, vex::voltageUnits::volt);
      lift2.spin(reverse, 8, vex::voltageUnits::volt);
      lift3.spin(reverse,7,vex::voltageUnits::volt);
    
    }
    else {
      lift1.stop();
      lift2.stop();
      lift3.stop();
    }
    
    if (Left1) {
      middlespin.spin(forward,4,vex::voltageUnits::volt);
    }
    else
    if (Left2) {
      middlespin.spin(reverse,4,vex::voltageUnits::volt);
    }
    else
    {
      middlespin.stop();
    }
  }  // ! while loop terminates here

  // this code will not run
  // it is outside the while loop
  
  if (Controller1.ButtonDown.pressing()) {
    lift3.spin(forward,7,vex::voltageUnits::volt);
  }
  else
  if (Controller1.ButtonUp.pressing()) {
    lift3.spin(reverse,7,vex::voltageUnits::volt);
  }
  else {
    lift3.stop();
  }
 
}
5 Likes

VEXcode V5 Pro has convenient document formatting included
also, use code folding to help show where braces match

vexcode_format

7 Likes