Accelerometer+Android

Hello! I am doing a project. I have an accelerometer connected to LilyPad. And the LilyPad is connected by bluetooth to a Android device. So an Android Application is receiving the values from the accelerometer.

In the application I hace a cube (OpenGL), so I want to move the cube in order to get the same inclination. I saw this:

float roll = Math.atan2((Math.sqrt((yvalue*yvalue)+(xvalue*xvalue))),zvalue)(180/(Math.PI)); float pitch = Math.atan2((Math.sqrt((xvalue*xvalue)+(zvalue*zvalue))),yvalue)(180/(Math.PI));

gl.glRotatef(pitch, 0.0f, 0.0f, 1.0f); gl.glRotatef(roll, 1.0f, 0.0f, 0.0f);

Where xvalue, yvalue and zvalue are the values I receive from the acceleromter of 3 axis. But it doesnt work! The cuve rotate a little, but not good.

Can anybody help me? Thanks!!

You need to show the inputs to your equations; saying it only rotates a little and it doesn't work helps no-one.

What is the orientation of your xyz axes at the home/normal position.

Those atan2() expressions should be much simpler like atan2(x, z) and atan2(y, z) - assuming z-axis is vertical.