Quote:
Originally Posted by MisterL
So my team wants me to program a photosensor in Java for our Autonomous code, but no matter where I look I can not find anything on any sample code that can help me. Is there anybody out there who can help me in the slightest? You help would be much appreciated 
|
Let me begin by saying the provided sensor code is garbage! I basically ended up ripping it apart and pretty much coding my own.
The sensors are DigitalInputs, and they have a get() function that returns true if the tape is sensed, false if not. See the example below.
Code:
DigitalInput middle, right, left;
public Robot() {
middle = new DigitalInput(1);
right = new DigitalInput(2);
left = new DigitalInput(3);
}
public void autonomous() {
if(middle.get()) {
// drive straight
} else if(right.get()) {
// drive left
} else if(left.get()) {
// drive right
}
}