I have an IMU sensor and all I’m trying to do is to read it’s measurent in a specific time gap using timer interrupts.
I have the examples for both the IMU and the timer interrupts and I just combined them.
Yet, the result is not good.
Each one of the two works separetly, but when I’m trying “imu.read” inside the interrupt - suddenly I get the error: “Failed to detect and initialized IMU!”
my code is:
volatile float ax; // global variable to be changed inside interrupt
// 5 next text lines are copied from the IMU example
Serial.println(“Failed to detect and initialize IMU!”);
// 2 next text lines are copied from the TimerOne example
void imuMessure(void) // This is the function I want the interrupt to exacute
ax = imu.a.x;
noInterrupts(); // stoping the interrupt from a moment just to get the value of ax
ax_copy = ax;
Serial.print("ax is "); // printing ax
Thank you very much!