This is the code from the project where I hacked a remote for an RC car to be driven by gravity, using a 3-axis accelerometer from Modern Device.