From 53b6c82dab184bcfa94e27f507e390e01d9ac476 Mon Sep 17 00:00:00 2001 From: niyatisriram Date: Sat, 19 Mar 2016 18:43:30 -0700 Subject: [PATCH] finish photogate insertion --- .../robot/commands/intakearm/Photogate.java | 14 +++++++++++--- .../robot/commands/intakearm/RunIntake.java | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) 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 -- 2.30.2