Overview
This example includes functions to initialize and read data from a Wii Nunchuck using an Arduino as an I2C interface. A sample VI is provided that shows how to implement these lower level functions.
Data available includes a three axis accelerometer, two axis joystick and two pushbuttons.
Description
The Wii Nunchuck is an increasingly popular input device that communicates via the I2C protocol. In this example we use the LabVIEW Interface for Arduino (LIFA) Toolkit to take I2C data from an Arduino and and then use Labview to convert the Nunchuck data in to usable values.
Of particular interest are the accelerometer readings; in order to represent the 10 bit resolution, the device uses 1 byte (8 bits) for each channel and then has an "aggregate" byte which contains the remaining two bits from each accelerometer reading in addition to the button press bytes.
The joystick uses one byte per axis and provides 8-bit resolution.
Steps to Implement or Execute Code
Requirements
Software
LabVIEW 2011, LabVIEW Interface for Arduino (LIFA) Toolkit
Hardware
Wii Nunchuck, Arduino board compatible with the LIFA toolkit
Additional Images or Video
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.