hi,
im using an ICM20649 from adafruit, it is unable to initialise the sensor if not started from a fresh upload - ie if i reconnect the usb or turn on the lip it will start the program but upon starting the ICM callout it fails. does anyone know why?
many thanks
#include <Adafruit_ICM20649.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
Adafruit_ICM20649 icm;
float gyroAvY;
int avNum = 10;
void setup(void) {
pinMode(LED_BUILTIN, OUTPUT);
if (!icm.begin_I2C()) { //try and connect using i2c, if this doenst work, flash the LED
for (int i = 0; i < 50; i++) {
digitalToggle(LED_BUILTIN);
delay(50);
}
}
for (int i = 0; i < 10; i++) { //show that start up is taking place
digitalToggle(LED_BUILTIN);
delay(500);
}
icm.setGyroRange(ICM20649_GYRO_RANGE_2000_DPS);
}
void loop() {
// /* Get a new normalized sensor event */
sensors_event_t accel;
sensors_event_t gyro;
sensors_event_t temp;
for (int i = 0; i < avNum; i++) {
icm.getEvent(&accel, &gyro, &temp);
gyroAvY += gyro.gyro.y;
}
gyroAvY = gyroAvY / avNum;
if (gyroAvY > 6) {
digitalToggle(LED_BUILTIN);
}
Serial.print(gyroAvY);
Serial.println();
}