Accelerometer Working Principle
Accelerometers measure linear acceleration and also gravity; the two are indistinguishable.
Thus they unavoidably function as tilt sensors as well. Inexpensive 1, 2, and 3-axis accelerometers are available which are constructed with MEMS techniques.
MEMS gyroscopes are also available, for measuring angular velocity, but are more expensive.