Hobby Projects‎ > ‎

# Accessing Wii accelerometer data in MATLAB

I compiled this dll by writing a C- MEX function. Using this file is very simple. Just download the dll file from the link below and save it in the work directory of MATLAB. The name of the dll is main and it returns three values corresponding to the accelerometer values. For example,

[accX accY accZ] = main();

This code will return the values of accelerometers X, Y and Z in accX, accY and accZ correspondingly.
Note: These are normalized values and hence are in the range of 0 to 1. To change it to the range of 0 to 9.8 simply multiply the results by 9.8

For example,

[accX accY accZ] =main();
accX = accX * 9.8;
accY = accY * 9.8;
accZ = accZ * 9.8;

To acccess the data periodically one can put the code in a loop. For example,

for i =1:100
[accX(i) accY(i) accZ(i)] =main();
accX = accX * 9.8;
accY = accY * 9.8;
accZ = accZ * 9.8;
end

main.dll

Thank you for all your love and support . Unfortunately the file was deleted from the server where I had uploaded earlier. I am sorry for the inconvenience it caused but now I have fixed it)

#### Connecting to PC and accessing the data in MATLAB

Description:
The Wiimote is first connected to the PC using Bluesoleil software. The Matlab plot shows the realtime change in the values of the accelerometer.

To download the matlab file to get a plot similar to one shown in the video click below:
wii_data_acquisition.m

Here's  a small demo if using Half-Life with my Wiimote