finish photogate insertion
authorniyatisriram <niyatisriram@gmail.com>
Sun, 20 Mar 2016 01:43:30 +0000 (18:43 -0700)
committerniyatisriram <niyatisriram@gmail.com>
Sun, 20 Mar 2016 01:43:30 +0000 (18:43 -0700)
src/org/usfirst/frc/team3501/robot/commands/intakearm/Photogate.java
src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java

index 9e6c2e8b5f1c000c8dd4c6b19c3542d9dbe6cea0..aff5fc2d623a2b2a6ee5a2003f49c34d34e87df8 100644 (file)
@@ -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;
   }
 
   /***
index 7625d6ab4f60904ef47232dcc1c25d94a4497f43..649ed5cf503232435539b6600a36f359a4d73f95 100644 (file)
@@ -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