If you only use a gyro, you can get quite a bit of drift. Gyros work well with low rates of change and accelerometers work well with high rates to change. If you use both, you can get a good number. To do this filtering and combination, there are a number of algorithms. A Kalman filter may be overkill but it will get the job done. Something a bit simpler would be a complimentary filter.
Here are some references to help you out:
Kalman Filter:
http://www.instructables.com/id/Guid...Arduino-inclu/
http://math.stackexchange.com/questi...-accelerometer
http://blog.tkjelectronics.dk/2011/0...h-the-arduino/
Complimentary Filter:
http://www.hobbytronics.co.uk/accelerometer-gyro
http://www.academia.edu/6261055/Comp..._and_Gyroscope
http://www.pieter-jan.com/node/11