View Single Post
  #3   Spotlight this post!  
Unread 18-02-2011, 19:46
Robby Unruh's Avatar
Robby Unruh Robby Unruh is offline
*insert random dial-up tone here*
FRC #3266 (Robots R Us)
Team Role: Coach
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Eaton, OH
Posts: 338
Robby Unruh will become famous soon enough
Re: Autonomous Photosensor Programming

Quote:
Originally Posted by MisterL View Post
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
    }
}
__________________
[Robots R Us #3266]
2015: Georgia Southern Classic (Winners / Thanks 1319 & 1648!), Queen City
2014: Crossroads, Queen City
2013: Buckeye, Queen City, Crossroads
2012: Buckeye, Queen City

2011: Buckeye
2010: Buckeye
Reply With Quote