Go to Post I feel that the only friends I have ever had are people I know through FIRST. Being on a team gave me the sense of belonging that I thought I didn't even need. FIRST has given me a great life that I never thought I would have. - Alaina [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
  #4   Spotlight this post!  
Unread 22-02-2016, 08:53
pblankenbaker pblankenbaker is offline
Registered User
FRC #0868
 
Join Date: Feb 2012
Location: Carmel, IN, USA
Posts: 102
pblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of lightpblankenbaker is a glorious beacon of light
Re: Arduino Ethernet with roboRIO

I didn't actually write the code on the LED side (we have a lot of kids on the team and gave that task to a group of them).

However, I'm pretty sure the following code fragment demonstrates how to detect the current LED mode (4 choices: 0, 1, 2 and 3) and whether the mode has just changed:

Code:
// Change to the I/O pins you used
// to connect your Arduino to your roboRIO
int ledControl0 = 8;
int ledControl1 = 9;

// Current LED operating mode
int curMode = -1;

void setup() {
  // Set up I/O pins for LED control as inputs
  pinMode(ledControl0, INPUT);
  pinMode(ledControl1, INPUT);
}

void loop() {
  // Assume no LED mode change
  int modeChanged = 0;
  // Start with mode 0
  int mode = 0;
  if (digitalRead(ledControl0)) {
    // Control line 0 set, add 1 to mode (set bit 1 in mode)
    mode = mode + 1;
  }
  if (digitalRead(ledControl1)) {
    // Control line 1 set, add 2 to mode (set bit 2 in mode)
    mode = mode + 2;
  }

  // Check to see if mode changed since last check
  if (mode != curMode) {
    curMode = mode;
    modeChanged = 1;
  }

  // At this point, curMode will be a value of 0, 1, 2 or 3
  // and modeChanged will be 1 if the mode has changed from
  // last invocation or 0 if it is the same as last time 

  // Add your code below to set your LED display output
  // accordingly ...

}
Hope that helps.
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 09:46.

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