Flywheel code not working

I switched to expert robot config and the code stopped working

  // check the ButtonL1/ButtonL2 status to control FlyWheel
  if (Controller1.ButtonL1.pressing()) {
    FlyWheel.spin(forward);
    Controller1LeftShoulderControlMotorsStopped = false;
  } else if (Controller1.ButtonL2.pressing()) {
    FlyWheel.spin(reverse);
    Controller1LeftShoulderControlMotorsStopped = false;
  } else if (!Controller1LeftShoulderControlMotorsStopped) {
    FlyWheel.stop();
    // set the toggle so that we don't constantly tell the motor to stop when the buttons are released
    Controller1LeftShoulderControlMotorsStopped = true;
  }

Hey,

I don’t know the problem there. If you send me the whole code, I can hopefully find it.

Nevertheless, instead of that part try this

if (Controller1.ButtonL1.pressing()) {
    FlyWheel.spin(forward);
    
  } else if (Controller1.ButtonL2.pressing()) {
    FlyWheel.spin(reverse);
    
  } else{
    
    FlyWheel.stop(); 
  }

It looks more clean

i figured it out i had a wait function in the wrong place earlier in the code

Careful having a reverse button on a flywheel. That is a lot of energy you can accidentally throw in the wrong direction.

4 Likes