Go to Post Every team should have a rule about not shouting "ROBOT!" when transporting a robot around the pits/arena. - frasnow [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-02-2015, 12:57
AquaWarrior12's Avatar
AquaWarrior12 AquaWarrior12 is offline
Registered User
FRC #2582 (Panther Bots)
Team Role: Programmer
 
Join Date: Dec 2013
Rookie Year: 2014
Location: Texas
Posts: 4
AquaWarrior12 is an unknown quantity at this point
Help Communicating the RIODuino with the RoboRIO

Hello fellow Programmers, I am in need of assistance. I am currently attempting to make a RIODuino communicate with the roboRIO. However, I have run into some difficulties concerning the code that allows them to communicate. I have this Java code, which reads:

Quote:
static I2C Wire = new I2C(Port.kOnboard, 4);

if (Global.driver.Buttons.Back.changedDown) {
String WriteString = "go";
char[] CharArray = WriteString.toCharArray();
byte[] WriteData = new byte[CharArray.length];
for (int i = 0; i < CharArray.length; i++) {
WriteData[i] = (byte) CharArray[i];
}
Wire.transaction(WriteData, WriteData.length, null, 0);
}
As it is, the Global reads as an error. If anyone can tell me how to fix this code, or potentially convert it to C++(which is how my team actually codes), then it would be greatly appreciated.
Also, the Arduino code reads:
Quote:
#include <Wire.h>

void setup()
{
pinMode (13, OUTPUT);
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
}

void loop()
{
delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
String LED = "";

while ( Wire.available() > 0 )
{
char n=(char)Wire.read();
if(((int)n)>((int)(' ')))
LED += n;
}

if (LED == "go")
{

digitalWrite (13, HIGH);


}
}
This Arduino code runs properly, or at least it appears so.
Again, any assistance in my problem would be greatly appreciated.
Thank you!
Reply With Quote
Reply


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:57.

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