I can print accelerometer values, but don't know how to convert these reading into rotationX,rotationY,rotationZ values I could use to spin a 3D cube in Processing for example.
Not sure about this, but accelerometer values are not X, Y, Z coordination. They are accelerations and vectors, but they can be used to find an angle. Gyroscope is rotation.
Not sure, like I said. Maybe a multi-axis can do it. Im currently reading the link... Nunchuck is 3 axis alright.
Thanks for the idea.
I could use that, but I don't know exactly how the the values map.
I imagined the values will be from 0 to 1023(like what analogRead() returns), but it seems like they could go to 255.
Also, I tried storing read values in a large array over time, while rotating the nunchuck, then getting the minimum and maximum values. The more 'samples' I took, the wider the ranges were, towards 255.
e.g.
minX = 27,maxX = 185;
then
minX = 55,maxX = 213;
then
minX=48,maxX=233
minY = 96,maxY = 246;
then
minY = 64, maxY = 255;
If the device measures acceleration it almost certainly uses a signed data representation, so where is your zero point?
Simple test: hold the device horizontal.
Now your x and y axes should read roughly zero, and your z axis should read a bout 1g
If I hold the device horizontal, I get these acceloremeter values:
x:47
y:170~180
z:217~220
y and z tend to change a bit even if I try to hold my hand still, while x barely changes, regardless of movement, this is using a nunchuck_print_data() call after nunchuck_get_data()
Sorry, I'm posting from my phone, and the browser doesn't let me scroll inside Code boxes, so I can't see all your code, so I can't comment further at the moment.
even horizontally you will probably get data. (since there is always some sort of acceleration or unbalanced mouvement)
as far as I know, the only way to get a Y value of 0 is a free fall ;D
try sending characters instead of numbers. i have done it and works fine. yet i have made a computer moues from Nunchuck. but rotating a cube should be a cakewalk. convert each movement of nunchuck in a specific character and send that alone to avoid synchronization issues. Have a look at my mouse code that has the nunchuk code also here: hardikpandya.com