Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrating servo command in subsystem #10

Merged
merged 2 commits into from
Jan 30, 2025
Merged
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
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ private void configureXboxControllerBindings() {
}, kSwerveDrive));

// servo testing
kDriverController.a().onTrue(new InstantCommand(() -> kCageTwist.latch(), kCageTwist));
kDriverController.b().onTrue(new InstantCommand(() -> kCageTwist.unlatch(), kCageTwist));
kDriverController.a().onTrue(kCageTwist.latch());
kDriverController.b().onTrue(kCageTwist.unlatch());
System.out.println("Xbox Controller Bound");

}
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/frc/robot/subsystems/TwistServo.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package frc.robot.subsystems;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

/** Testing servo */
public class TwistServo extends SubsystemBase {
Servo twist = new Servo(0);

public void latch(){
twist.setAngle(90);

public Command latch() {
return this.runOnce(() -> twist.setAngle(90));
}

public void unlatch(){
twist.setAngle(180);

public Command unlatch() {
return this.runOnce(() -> twist.setAngle(180));
}

}