How to: tilt measurement with an accelerometer?

I have an adxl335 accelerometer working with an arduino duemillanove.

I used a example sketch, included in the arduino 0017 software, to read acceleration. It seems to run, but i am interested on tilt measurement.

There are different post at this forum related to this and other accelerometers, but in any case is explained how to measure tilt by this sensor.

Any idea?

Thanks in advance!

I saw this equation on internet, but i am not sure if it is correct and how to apply it...

Vout = Voffset + [(AV/Ag)x1gxsinB]

where:
Vout is the voltage readed into the analogical pin (calculated from the lecture from the 1024 levels)
Voffset is the voltage at 0g acceleration
AV/AG is the sensibility
g is the gravity on earth
and B is the tilt angle.

I suppose that Voffset is the voltage when the sensor is not in movement and the lecture in arduino is 512 --> 2.5Volts. Is it correct?

Other problem is how to know the sensibility AV/Ag. is it located in the datasheet?

i suppose that g could by 9.8 m/s^2, although an aprox. of 10 m/s^2 could be also valid.

So, in theory, the final equation to derive B is:

B = arcsin [(Vout-Voffset)/(AV/Ag)]

In theory we obtain the tilt angle B in degrees for one of the axis. If we repeat the calculation taking into account the values of the different pins, we could obtain the tilt for x, y and z

So, is it right?

UPDATE: here it is where is saw the equation:
http://www.freescale.com/files/sensors/doc/app_note/AN3107.pdf

UPDATE 2: here there is more information
http://www.freescale.com/files/sensors/doc/app_note/AN3461.pdf

Other problem is how to know the sensibility AV/Ag. is it located in the datasheet?

300mV per g (VS = 3V) from the datasheet.

Make sure your input data is well filtered - the sine of a small angle is also very small.

Thanks AWOL,

I will try to develop an sketch along this weekend and post it here soon.