Dual Motor Voltage not starting in Autonomous

Hello, I am fairly beginner level to C++ and am having trouble with my dual motor flywheel for Vex V5 Spin up. I am having trouble turning on both motors (in a motor group). It uses voltage, and I have tried many different types of lines like spinFor, or even spin(). I have a competition coming up this weekend and I really need some help. Here is my code:
MAIN.CPP

void pre_auton(void) {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}


void autonomous(void) {
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................


  Drivetrain.driveFor(forward,2, inches);
  Intake_Roller.spinFor(forward,.25,turns);
  Drivetrain.driveFor(reverse,5,inches);
  Drivetrain.turnFor(left,75,degrees);
  Flywheel.spinFor(forward, 75, turns);

}


int main() {
  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

  Indexer.setVelocity(50, percent);
  Intake_Roller.setVelocity(100, percent);
  // Run the pre-autonomous function.
  pre_auton();

  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);
  }
}

ROBOT CONFIG

//F L Y  W H E E L  C O D E
      if (Controller1.ButtonL1.pressing()) {
        Flywheel.spin(forward, 10, voltageUnits::volt);
      } else if (Controller1.ButtonL2.pressing()) {
        Flywheel.spin(reverse, -10, voltageUnits::volt);
      } else {
        Flywheel.stop();
        // set the toggle so that we don't constantly tell the motor to stop when the buttons are released
        Controller1LeftShoulderControlMotorsStopped = true;
      }

edit: mods fixed the code tags for you, use three back ticks

Is this the code not working ?
All the drivetrain commands would need to finish before that line of code is reached.

or this ?
controller is disabled during autonomous.

perhaps explain a little more about what doesn’t work.

5 Likes

Sorry for the vague parts. However, I believe the second issue with it is why it’s not doing it because it says controller.pressed() but it’s autonomous not driver controlled. How would I fix it?

I can’t seem to figure out how to fix it @jpearman

just add a line like this

Flywheel.spin(forward, 10, voltageUnits::volt);

to the beginning of autonomous.

you may need to disable the auto generated task, there’s a flag for that, downside of using the graphical configuration.

remoteControlCodeEnable = false;
void autonomous(void) {
  remoteControlCodeEnable = false;
  
  Flywheel.spin(forward, 10, voltageUnits::volt);
  // perhaps wait for flywheel to get up to speed

  // more code here.
}
3 Likes

Thank you! I will try that. Just to clarify though, this is all in main.cpp correct? @jpearman