Skip to content

Commit

Permalink
Added second motor and ElevatorDown.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonube committed Jan 15, 2025
1 parent 38b41f4 commit 1d8407d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 22 deletions.
24 changes: 24 additions & 0 deletions main/java/frc/robot/Commands/frc/robot/commands/ElevatorDown.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Elevator;

public class ElevatorUp extends Command {
private final Elevator elevator;

public ElevatorDown(Elevator elevator) {
this.elevator = elevator;

addRequirements(elevator);
}

@Override
public void execute() {
elevator.down();
}

@Override
public void end(boolean interrupted) {
elevator.hold();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ public void execute() {
public void end(boolean interrupted) {
elevator.hold();
}

}
}
8 changes: 4 additions & 4 deletions main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public static final class DriveConstants {
public static final int kRearRightTurningCanId = 16;

public static final boolean kGyroReversed = false;
}

public static final class ElevatorConstants {
public static final int ElevatorMotorRight = 20;
public static final int ElevatorMotorLeft = 21;
}

public static final class ElevatorConstants{
public static final int ElevatorMotor = 20;
}

public static final class ModuleConstants {
// The MAXSwerve module can be configured with one of three pinion gears: 12T,
Expand Down
2 changes: 1 addition & 1 deletion main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import frc.robot.Constants.DriveConstants;
import frc.robot.Constants.OIConstants;
import frc.robot.subsystems.DriveSubsystem;
import frc.robot.subsystems.Elevator;
import java.util.List;

/*
Expand All @@ -36,7 +37,6 @@ public class RobotContainer {
private final DriveSubsystem m_robotDrive = new DriveSubsystem();
private final Elevator elevator = new Elevator(20);


// The driver's controller
XboxController m_driverController = new XboxController(OIConstants.kDriverControllerPort);
private final ElevatorDown down = new ElevatorDown(elevator);
Expand Down
33 changes: 18 additions & 15 deletions main/java/frc/robot/subsystems/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,37 @@
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.ElevatorConstants;

public class Elevator extends SubsystemBase{
private final CANSparkMax ElevatorMotor;

public Elevator(int ElevatorMotorID) {
ElevatorMotor = new CANSparkMax(ElevatorConstants.ElevatorMotor, CANSparkMax.MotorType.kBrushless);

public class Elevator extends SubsystemBase {
private final CANSparkMax ElevatorMotorRight;

public Elevator(int ElevatorMotorRightID, int ElevatorMotorLeftID) {
ElevatorMotorRight =
new CANSparkMax(ElevatorConstants.ElevatorMotorRight, CANSparkMax.MotorType.kBrushless);
ElevatorMotorLeft =
new CANSparkMax(ElevatorConstants.ElevatorMotorLeft, CANSparkMax.MotorType.kBrushless);
}

// Spins intake motor to intake notes
public void up() {
ElevatorMotor.set(1);
ElevatorMotorRight.set(1);
ElevatorMotorLeft.set(1);
}

public void down() {
ElevatorMotor.set(-1);
ElevatorMotorRight.set(-1);
ElevatorMotorLeft.set(-1);
}

public void hold() {
ElevatorMotor.set(0);
ElevatorMotorRight.set(0);
ElevatorMotorLeft.set(0);
}

@Override
public void periodic() {

}
public void periodic() {}

public void stop() {
ElevatorMotor.stopMotor();
ElevatorMotorRight.stopMotor();
ElevatorMotorLeft.stopMotor();
}

}
}

0 comments on commit 1d8407d

Please sign in to comment.