Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void teleopInit() {
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
}

}

@Override
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/frc/robot/commands/SpinMotor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.commands;

import edu.wpi.first.wpilibj.Timer;
import frc.robot.subsystems.basicTestbed.TestbedSubsystem;

public class SpinMotor {
private TestbedSubsystem neoMotor;

private double startTime;
private double speedMotors;

public SpinMotor(TestbedSubsystem neoMotor, double speedMotors) {

this.speedMotors = speedMotors;
this.neoMotor = neoMotor;
}

// Called when the command is initially scheduled.
public void initialize() {
neoMotor.setSpeed(speedMotors);
startTime = Timer.getFPGATimestamp();
}

// Called every time the scheduler runs while the command is scheduled.
public void execute() {}

// Called once the command ends or is interrupted.
public void end(boolean interrupted) {
neoMotor.stop();
}

// Returns true when the command should end.
public boolean isFinished() {

return (Timer.getFPGATimestamp() - startTime >= 5);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package frc.robot.subsystems.basicTestbed;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import com.revrobotics.spark.SparkLowLevel;
import com.revrobotics.spark.SparkMax;


public class TestbedSubsystem extends SubsystemBase {
private final SparkMax myMotor;

public TestbedSubsystem() {
this.myMotor =
new SparkMax(3, SparkLowLevel.MotorType.kBrushless);
}

public void setSpeed(double speed) {
myMotor.set(speed);
}

public void stop() {
myMotor.set(0);
}
}