Connecting a Arduino to a cRio to control LEDs

We are trying to use LEDs on our robot, so we purchased the LED kit on AndyMark which includes an Arduino controller (an ATMega328). we also downloaded the Aduino library for labview. In the LED examples there were a couple terminals in the initialize VI that I had a few questions about.

  1. What is the VISA resource?
  2. What is a XBEE connection and where is the serial port that I can connect the Arduino to the cRio?

VISA is a communication abstraction that is most likely wrapping serial communications for your device. The example code should demonstrate how you specify the serial port to use.

Greg McKaskle

The example code only shows how to connect the arduino with the LEDs not the arduino micro-controller to the cRio. Some of my team believes that the miro-controller is not the same as an arduino controller. Would this make a difference because when we try to load the LabView base sketch onto the arduino it gives us a sync error.

We are using an Arduino Pro Mini to control a strip of 26 addressable LEDs. We we are using 4 DIO pins from the DSC to connect to 4 DIO pins on the Arduino. The strip gives our drivers a visual relative distance indication.
Although we could set up 16 different patterns, each indicating distance, we are only using 8. We have found that finer resolution of distance is just not needed.

Last year we used I2C to successfully control an Arduino.

You can see the Java command here:

And the Arduino code here:

Note the address used by the cRio is 2 * the address used on the arduino.

If you choose i2c, you will also need to use the ribbon cable to connect the cRio to the digital breakout.

I still cannot figure out how to use the arduino Atmega 328 micro controller in conjunction with LabView and the cRio to control the 8.2 ft Led light string.

I have not tried using LabView with an Arduino of any flavor, although I know it is possible.

We are running our Arduino as a stand alone device that is programmed in the Arduino IDE.
We “communicate” with it by simply using the digital inputs on the Arduino connected to digital outputs on the DSC.
The Arduino code just looks at the state of the digital inputs and runs the code associated with their state(s).
The Digital Outputs from the cRio (DSC) are boolean outputs, either HIGH or LOW.
There are multiple ways to communicate with the Arduino from the cRio. Just choose a process you understand.

Last year we also used digital outputs from the DSC for state and PWM outputs from the DSC to transmit continuous values. The continuous values allowed us to display wheel speed as a moving bar graph on LED strips attached to the robot. It was also a handy visual to verify that the encoders were working.
The Arduino code is on our Google Code repository

We’re trying to do the same thing and running into the same problem of not knowing what VISA Resource Name to use. I assume we need to know the name that indicates the RS232 port on the cRIO.

XBEE makes a series of little radios that you can communicate over as if they are RS232 Serial ports. They are commonly used in small robots to provide a link back to a controlling computer or in a mesh network.

While there are other good ways to communicate between the cRIO and the Arduino, including I2C and GPIO lines, I’d prefer to use RS232 because we’re actually controlling a 32x32 array of LEDs and would like to let the cRIO send us strings to display on the array.

So, please, if anyone out there knows how to make this work, please post a reply. If I figure it out, I’ll post a reply here, myself.


Try “COM1” without the quotes. That is what you would commonly use on the desktop and is the example given when you hover over a VISA refnum or terminal.

That is actually an alias for “ASRL1::INSTR”, which is the full name that VISA uses to describe the serial port.

For more documentation, here is a VISA manual.

Serial ports addresses are on page 18 of chapter 9.

Greg McKaskle

I finally discovered how to get the cRIO to talk to the Arduino. Well, actually, I found someone who knew who sent me some example code that was very helpful.

The key is to use the Serial library that’s in the WPI Library, not the one in the instrument library. Once you know that, it’s pretty easy to figure out the rest. Set your serial port up to whatever baud rate you plan to use, configure to 8-bits, no parity, 1 stop bit. We have very short messages so had no need for flow control. To send messages from the cRIO to the Arduino, I’m sending single characters followed by a newline and then flushing the buffer.

If you’re using an Arduino Uno or equivalent, you just read and write to the Serial port just as if you were doing so for the Serial Monitor in the IDE. Since we’re using an Arduino Mega 2560, which also has hardware support for Serial1, Serial2, and Serial3, we’re using Serial1 so we can still use Serial to send diagnostic messages to the Monitor.

I’m going to set up an Instructable or something to make this a little easier. I’ll post here when that’s done.

Good Luck,