Last year we used a string of blue LED’s on our robot to indicate robot status to our drivers. This year we want to use RGB LED’s to indicate more events. The plan is to use a rioduino over the I2C bus (Either onboard, or through MXP slot), to control a strand of LEDs. I have seen the labview example, and the touchscreen example, but we program in JAVA. Also, I’m trying to simplify the code by only sending a single character per status to the Rioduino. I would have a case switch in the Rioduino C# code with the different LED patterns. The sticking point seems to be in the JAVA code for sending characters. I just can’t figure out I2C api notes. I can post both my arduino and java code if people are interested. Any notes, hints, example code or tutorials are appreciated.
I’m not sure how to do this with I2C as we used serial but we appear to think alike, as I sent single characters last season (over serial). Worked great!
Thanks, although, that doesn’t seem like enough code. How does the mode change? Does it send the entire string " Pulse_Color" or just a single character? Additionally, do you have your rioduino side code?
mode.ordinal returns the position of the value as an integer (Eg. passing Mode.PULSE_GREEN to setMode will result in a 1), which is then type-casted to a char.
The code for the RIODuino is also on our github. It’s basically the example code from Andymark’s page, with some modifications.
Our team isn’t using a Rioduino, but from what I read it’s basically just an Uno R3, right? If there’s a fundamental difference in the operation then the following may be invalid:
We’re currently using a plain-old Uno R3 hooked to the RoboRio via the dedicated I2c connection and the kids are using the following code on the Rio in the Java program:
static I2C arduino;
...
(in robotInit)
arduino = new I2C(I2C.Port.kOnboard, 4);
...
static void UpdateLEDs(String WriteString)
{
char] CharArray = WriteString.toCharArray();
byte] WriteData = new byte[CharArray.length];
for (int i = 0; i < CharArray.length; i++) {
WriteData* = (byte) CharArray*;
}
arduino.transaction(WriteData, WriteData.length, null, 0);
}
Then they call “Robot.UpdateLEDs([mode])” with a given game-mode, such as “TELEOP”.
@Muskie Thanks for clarifying that and sharing your 'duino code. I’ll test it out as soon as the kids let me have the RIO for 10 mins.
@ mrEkko Super thanks for the JAVA code, that was the part I was struggling with the most. Ditto for 'duino code. One question, what was the object “LED” declared as? The compiler does not like that it does not have a declaration.
We have strips of NeoPixel LEDs (digital) and we use the Arudino_NeoPixel library. More information about the LEDs and the library can be found at the following links: https://www.adafruit.com/category/168