Example Code

Using an Arduino with LabVIEW (Ethernet Shield)

Code and Documents

Attachment

Download All

Description

 

The following sample code allows LabVIEW to communicate with an Arduino Uno fitted with an Ethernet shield.

 

The LabVIEW code consists of three sample VIs, one is used to talk to the Arduino using the LabVIEW TCP functions, the other VIs demonstrate checking the board is connected and controlling a digital output.

 

Simple single byte commands are sent to the Arduino along with any required data, and the Arduino always sends back a reply. In this way no other handshaking is required, and this method has so far been proven to be 100% reliable.

 

Hardware and Software Requirements

 

LabVIEW 2010 or later, Arduino Uno compatible board, Ethernet shield.

 

LabVIEW Functions

 

The Write Read VI opens a TCP connection to the board, sends out a simple string, then waits for a reply.

 

1.png

 

The Check Connected VI sends a single "A" character to the board then waits for the string "Arduino" to come back. This proves that the board is connected and communicating correctly.

 

2.png

 

The Set Digital Output VI is an example VI showing how simple digital control can be. It sends a single "B" character followed by a "0" or "1" which is used to set a digital output either high or low.

 

3.png

 

The sample code for the Arduino is included in the downloads.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors