Hi,
I try to use LSM6DSO captor, I follow this guide Arduino | LSM6DSOX, ISM330DHC, & LSM6DSO32 6 DoF IMUs | Adafruit Learning System
I've created a file captor_function.cpp, in this file I would like to put some functions to use with my captor.
For the moment I try just to find the captor. So if I follow the guide I need to use begin_I2C() function.
So in my cpp function file I've created a function called initiateCaptor() with one parameter the captor like that
void initiateCaptor(Adafruit_LSM6DSO32 captor);
My cpp
void initiateCaptor(Adafruit_LSM6DSO32 captor){
SerialUSB("Begin initiate");
if (!captor.begin_I2C()) {
while (1) {
delay(10);
}
}
SerialUSB("Find it!");
}
Ok so this is easy. In my ino file I include my header and in my setup I called this function.
#include <Adafruit_LSM6DSO32.h>
Adafruit_LSM6DSO32 dso32;
void setup() {
SerialUSB.begin(115200);
while (!SerialUSB)
delay(10);
initiateCaptor(dso32);
}
void loop() {
// put your main code here, to run repeatedly:
}
But if I do thaht I never see the message Find it! I only see Begin initiate. This is strange because if I put the while and the delay in the setup this is works I find my captor, but if I put that in a function my captor is nerver find why?
I also try to give captor by a pointer in my function same result. I have no error when the compilation stage is called. It's look like the program stay in the while(1)...