Guide to gyro and accelerometer with Arduino including Kalman filtering

I really haven't got the time to play around with it :frowning: But if you succeed in getting 360 degrees resolution, please post the code, and I will update it :slight_smile:
I am thinking about buying a magnetometer, and update the guide, so one can calculate yaw as well. But that might be in the future, as I have so many things going on right now! :frowning:

I think you could minimize the lag, by doing something like this:

int STD_LOOP_TIME = 10;            
int lastLoopUsefulTime = STD_LOOP_TIME;
unsigned long loopStartTime = 0;

setup()
{
//some code
}
loop()
{
//Calculate the angles

lastLoopUsefulTime = millis()-loopStartTime;
if(lastLoopUsefulTime<STD_LOOP_TIME)         
    delay(STD_LOOP_TIME-lastLoopUsefulTime);
loopStartTime = millis();
}

Then it will only read the IMU every 10 ms - that might do the trick :slight_smile: