|
Re: Connecting a Arduino to a cRio to control LEDs
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,
Ray
|