Overview
The attached code allows you to use your Wii Nunchuck as a mouse for your PC.
Description
Using this example as a starting point, one is able to use their white Wii Nunchuck as a mouse for their Windows PC.
One novel method used in this example is the calibration process. By default the joysticks on Wii Nunchucks are not terribly accurate. As a result using it for a mouse in an uncalibrated state is a frustrating experience at best. This program actually uses an image processing algorithm to do this calibration.
First a baseline image is created with two even gradient color planes, one color plane of which represents the X-axis and the other which represents the Y-axis. In theory the pixel value in the center of the left hand edge of the image will correspond to the centerpoint of the Y-axis and leftmost extreme of the X-axis, the centerpoint of the top edge would correspond to the centerpoint of the X-axis and uppermost value of the Y-axis, etc.
In order to do the calibration, a reading is taken at each extreme of the joystick during the calibration phase. This reading is then converted to a pixel value. Using a shephard's transformation, the baseline image is transformed such that the resulting image has a distorted gradient with pixel values at each of the extremes corresponding to the measured pixel values. The remainder of the distorted gradient then represents an approximate map of the non-linearity of the joystick. Thus, a lookup table is created.
This transformation is done with the open source ImageMagick .dll, which is included in this distribution under the Apache 2.0 license.
NOTE: While running this .vi your default mouse will temporarily be disabled.
Steps to Implement or Execute Code
Requirements
Software
LabVIEW 2011 or newer
LabVIEW Interface for Arduino
ImageMagick (included)
Hardware
Arduino Uno, Mega 2560 or Duemilanove
White Wii Nunchuck
Wii Nunchuck connector adapter (optional)
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Great information... Thank you so much