How to save a constant updating value

hmm some side notes.
So the angle is from a device (bike) that can turn over (fall)..

Hmm it might be hard to balance something if thats your goal.
There are accellero meters and there are things who precizely measure an angle but no acceleration.
The math to balance is kinda complex dough there was an article recently i tink on "hack a day" website..
Dough, it might perhaps be an idea to not use complex math for it, but train a more general neural net (there is even a neural net example for arduino)
Training dough will require a lot of falling, but eventualy by learning such software will work (hey even you i can walk by using our real neurons).
I remember for (real) long time ago such neural software has been used on targeting rockets, and kept better track under real world conditions (wind, unstable engines etc).
It wont be easy but.. if learning was your goal.. there is a lot one can learn from it.