When you do not have any motor ports left on your robot, Spark minis are a great way to control your motor.
You can not use encoders with Spark Minis
Wiring:
Spark Minis get plugged into the servo port. In your configuration go to the servo menu and select Spark Mini.
Code:
@TeleOp
public class SparkMiniExample extends LinearOpMode {
DcMotorSimple motor;
@Override
public void runOpMode() {
motor = hardwareMap.get(DcMotorSimple.class, "motor");
// Wait for the game to start (driver presses PLAY)
waitForStart();
// run until the end of the match (driver presses STOP)
while (opModeIsActive()) {
motor.setPower(gamepad1.left_stick_y);
}
}
}
Spark Minis use the DcMotorSimple class while a regular DcMotor uses uses the DcMotor class.