Go to Post Bottom line - keep your passion for FIRST and don't let others spoil your fun! - Sean Schuff [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi