ddb5247217eb9ec27e43d3acd2d530300d3e6ad4
1 package org
.usfirst
.frc
.team3501
.robot
.sensors
;
3 import edu
.wpi
.first
.wpilibj
.AnalogInput
;
5 // TODO: Change certain reactions based on testing, ie what value(s) return true
6 // and what value(s) return false.
9 * The photogate is a pair of IR LED and phototransistor sensor that uses a
10 * reflective method to sense the presence of the boulder within the robot's
11 * shooting chamber. This class specifically checks for the ball's presence
12 * using a threshold of voltages outputted from the phototransistor.
14 * @author niyatisriram
16 public class Photogate
extends AnalogInput
{
18 private double threshold
;
21 * The constructor inputs the channel of the transistor and the threshold
23 * The threshold is a specific value, representing the outputted voltage of
24 * the phototransistor. This value will be somewhere within the range [0,
25 * 4095] Find the value by testing and finding an average value for which the
26 * ball is present when the output is greater, and absent when the output is
29 public Photogate(int channel
, int threshold
) {
31 this.threshold
= threshold
;
35 * @return whether the ball is present or not
37 public boolean isBallPresent() {
38 if (this.getValue() > threshold
)
49 public void setThreshold(int threshold
) {
50 this.threshold
= threshold
;