Skip to content

Commit

Permalink
Merge pull request #34 from 2491-NoMythic/Adding-Sensor
Browse files Browse the repository at this point in the history
added distance sensor how we want it
  • Loading branch information
rflood07 authored Jan 31, 2024
2 parents 4588f40 + 7990ad9 commit eab61c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/main/java/frc/robot/commands/IndexCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ public void initialize() {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if (m_Indexer.getInchesFromSensor()>8) {
if (!m_Indexer.isNoteIn()) {
intake.intakeYes(1);
m_Indexer.on();
shooter.turnOff();
} else {
intake.intakeOff();
m_Indexer.off();
if(!shootButtonSupplier.getAsBoolean()) {
m_Indexer.off();
}
shooter.shootThing(1);
}
if (shootButtonSupplier.getAsBoolean()) {
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/frc/robot/subsystems/IndexerSubsystem.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package frc.robot.subsystems;

import com.revrobotics.CANSparkMax;
import com.revrobotics.SparkAnalogSensor;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.revrobotics.SparkAnalogSensor.Mode;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.settings.Constants.IndexerConstants;

public class IndexerSubsystem extends SubsystemBase {
CANSparkMax m_IndexerMotor;
SparkAnalogSensor m_DistanceSensor;

public IndexerSubsystem() {
m_IndexerMotor = new CANSparkMax(IndexerConstants.INDEXER_MOTOR, MotorType.kBrushless);
m_DistanceSensor = m_IndexerMotor.getAnalog(Mode.kAbsolute);
}

public double getInchesFromSensor() {
return 0;
public boolean isNoteIn() {
return m_DistanceSensor.getVoltage()>1;
}

public void on() {
Expand Down

0 comments on commit eab61c9

Please sign in to comment.