From: niyatisriram Date: Sun, 20 Mar 2016 01:43:30 +0000 (-0700) Subject: finish photogate insertion X-Git-Url: http://challenge-bot.com/repos/?p=3501%2Fstronghold-2016;a=commitdiff_plain;h=53b6c82dab184bcfa94e27f507e390e01d9ac476 finish photogate insertion --- diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java index 9e6c2e8b..aff5fc2d 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java @@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj.AnalogInput; public class Photogate extends AnalogInput { private double threshold = 1.8; + static boolean ballState; /*** * The constructor inputs the channel of the transistor and the threshold @@ -26,6 +27,7 @@ public class Photogate extends AnalogInput { public Photogate() { super(0); this.threshold = threshold; + } /*** @@ -33,11 +35,17 @@ public class Photogate extends AnalogInput { * USE TO DECIDE WHEN OUTTAKE NEEDS TO HAPPEN FOR BALL TO BE SECURE */ public boolean isBallPresent() { - if (this.getVoltage() > threshold) + if (this.getVoltage() > threshold) { + ballState = true; return true; - else - return false; + } else + ballState = false; + return false; + + } + public static boolean ballState() { + return ballState; } /*** diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java index 7625d6ab..649ed5cf 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java @@ -25,8 +25,8 @@ public class RunIntake extends Command { @Override protected void execute() { - // if Photogate.() { - Robot.intakeArm.outputBall(); + if (Photogate.ballState()) + Robot.intakeArm.outputBall(); } @Override