Arduino + Lego NXT

The integration happens inside Arduino.
I preferred not to do hardware integration because I hoped that software could give me more flexibility.

I chose the fastest sampling time I could, which is 4 ms (--> 250 Hz).
I first used the rectangle method for integration but now I've preferred the trapezoid method to minimize the error: what I've found out is that most of the error comes from (1) the sensor and (2) ADC approximation.

Anyone going to replicate this robot should use an angle sensor (maybe I2C based) instead of a gyroscope; integration is bringing avoidable error.