diff --git a/src/MPU6050.cpp b/src/MPU6050.cpp index eb1d2d8..b18ac6a 100644 --- a/src/MPU6050.cpp +++ b/src/MPU6050.cpp @@ -3436,6 +3436,7 @@ void MPU6050_Base::PID(uint8_t ReadAddress, float kP,float kI, uint8_t Loops){ } } for (int i = 0; i < 3; i++) { + if (isnan(Reading[i])) {Reading[i] = 0;} Error = -Reading[i]; eSum += abs(Reading[i]); PTerm = kP * Error; @@ -3492,4 +3493,4 @@ void MPU6050_Base::PrintActiveOffsets() { Serial.print((float)offsets[3], 5); Serial.print(",\t"); Serial.print((float)offsets[4], 5); Serial.print(",\t"); Serial.print((float)offsets[5], 5); Serial.print("\n\n"); -} \ No newline at end of file +}