Arm position code not working

I am trying to code my robot arm to move down if it goes too high but the code is not working. it never goes back down if it goes too high. This is the code that I have right now.

int main() {
  while (1) {
   
    TurretMotor1.setVelocity(Controller1.Axis4.position(), percent);
    armMotor2.setVelocity(Controller1.Axis3.position(), percent);
    TurretMotor1.spin(forward);
    armMotor2.spin(forward);
    /*
    Controller1.Screen.print(PotentiometerA.angle(percent));
    //Controller1.Screen.print();
    wait(0.1, seconds);
    Controller1.Screen.clearLine(1);
    */
    Controller1.Screen.print(PotentiometerA.angle(percent));
    wait(.1, seconds);
    Controller1.Screen.clearScreen();
    Controller1.Screen.setCursor(1, 1);
    
    if (PotentiometerA.angle(percent)>95) {
      armMotor2.stop();
      armMotor2.setVelocity(50, percent);
      armMotor2.spin(forward);

      
    }
    
  }  
}

I know nothing about this, but it seems that maybe the arm has no time to go back down because it is instantly set back to the controller velocity before it can move? So maybe you should add a line that makes the code wait for a bit.

1 Like