LSM303DLH roll, pitch and yaw


I recently bought the LSM303DLH module (3 axis accelerometer and 3 axis compass).

I want to do something like this:

or this:

I don’t know if it is necessary a gyro too or with the accelerometer and compass is enough.

I can get pitch 360º with the next formula:

pitch = atan2(z, y);

I can get roll 360º with the next formula:

roll = atan2(x, y);

I can get yaw 360º with compass values

However, what is the formula to obtain pitch, roll and yaw at the same time to rotate a cube in all directions?

Thank you.


Yes, you need the gyro if you want it to be sensitive to quick changes in rotation. If you are happy with a really slow version of what is in the videos, you don’t need the gyros.

Sorry, what are you asking?

- Ryan

Hello, osropa,

We are working on a single board that combines the LSM303 with an L3G4200D 3-axis gyro, which we expect to be available in a week or two. Since you already have an LSM303DLH, though, you might just want to consider adding an L3G4200D carrier board to your system if you decide that you also want a gyro.

- Kevin