Hey, as I said, Serial.print prints the data of the accelerometer with the previous data from the gyro. Then its prints the previous data from the accel with the current data from the gyro.
Here’s the function:
if (myIMU.dataAvailable()) {
float a_x = myIMU.getLinAccelX();
float a_y = myIMU.getLinAccelY();
float a_z = myIMU.getLinAccelZ();
float a_accy = myIMU.getLinAccelAccuracy();
float beta = myIMU.getGyroZ();
float beta_accy = myIMU.getGyroAccuracy();
Serial.print(a_x, 2); //0
Serial.print(F(“^”));
Serial.print(a_y, 2); //1
Serial.print(F(“^”));
Serial.print(a_z, 2); //2
Serial.print(F(“^”));
Serial.print(a_accy, 3); //3
Serial.print(F(“^”));
Serial.print(beta, 2); //4
Serial.print(F(“^”));
Serial.print(beta_accy, 2); //5
Serial.println();
//delay(16);
}
Here is an example of the data.
-1.68^1.04^-3.46^3.000^-2.34^0.00
-1.68^1.04^-3.46^3.000^-3.89^0.00
0.11^0.14^-1.44^3.000^-3.89^0.00
0.11^0.14^-1.44^3.000^-2.20^0.00
0.27^-6.89^1.24^3.000^-2.20^0.00
0.27^-6.89^1.24^3.000^2.07^0.00
2.52^-3.25^2.48^3.000^2.07^0.00
2.52^-3.25^2.48^3.000^1.60^0.00
It does this at any frequency (1hz, 10 hz, 90 hz) and even if i add delay between each cycle(loop).
How can I make it so the gyro and accelerometer are synced and I dont get 2 prints from serial? (rootcause please, not just a side code to cope with the problem…!)
Thanks.
-Jm