Can't get NEO Vortex with Spark Flex controller to run using code

We are trying to run our NEO Vortex’s with the Spark Flex motor controller with code, but are unable too. Running them in the REV Hardware client works, but we are unable to run them any other way.

package frc.robot.subsystems;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import com.revrobotics.CANSparkFlex;
import com.revrobotics.CANSparkLowLevel.MotorType;

public class testNeoMotor extends SubsystemBase {

    private static testNeoMotor instance;
    public static testNeoMotor getInstance() {
        if (instance == null) instance = new testNeoMotor();
        return instance;
    }

    private CANSparkFlex testMotor;

    public testNeoMotor() {
    testMotor = new CANSparkFlex(23, MotorType.kBrushless);
    }

    public void spinMotor(double voltage) {
        testMotor.setVoltage(voltage);
    }

    @Override
    public void periodic() {
    
  }
}

^^^ This is our subsystem code for the motor (we do have code in the robot container file to spin the motor at 6 volts when a button on the controller is pressed)

We are running the newest version of WPILib with the latest REVLib and newest firmware for the motor controller. We have tried all of the troubleshooting steps and are still unsure of the problem

Any help would be appreciated!

An interesting “feature” built into the spark flexes is that they will not run on the RIO’s CAN network messages after being connected to the hardware client. This was added in order to prevent the flex from being given two instructions from two different sources at the same time. I would disconnect the flex from the CAN network, power cycle the robot, then reconnect the flex. I am not sure about the code as that’s not my area of expertise but it seems as though this is probably what is happening based on your problem.