This is just a basic code snippet for the time being, but please feel free to contribute more information
Gyroscopes measure the rate of change of a particular axis at the current moment in time. This means that to keep track of our angle, we need to sum all of the rates of change over a given period of time. We're essentially looking for the integral of our gyro data. In the sample code below we'll be looking at just one gyro axis.
First off, you'll want to set the voltage of your gyro (typically 3.3v or 5v) for the gyroVoltage variable. This will setup how the values are scaled.
Next you'll need to know the zero voltage of your gyro. You'll be able to find this in the gyro's datasheet. It is sometimes called the Null voltage. In this example, I set the gyroZeroVoltage to 2.5. This is the voltage your gyro normally outputs when it's not rotating.
The other value you'll need from the datasheet is the sensitivity. This is expressed in mV/degree/second. Since this is mV, we need to convert to volts. You'll see in the examples, my gyro had a sensitivity of 7mV/deg/sec.
The Arduino has 10 bit ADC which can represent a voltage (0-5V) in values from 0 to 1023. Unfortunately you'll definitely see error building up over time since we can never get a perfectly accurate voltage reading from the gyro and our numbers never divide out evenly. You can set the rotationThreshold to a minimum degree/second that the gyro has to be detected rotating at. If this degree/second rate is not met, the data will be discarded.