You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
figuring the chip. But the library is a bit of.
the tap example is not working. There are used the wrong register.
Here an example how I was able to run the tap function.
`#include "SparkFunLSM6DS3.h"
#include "Wire.h"
LSM6DS3 myIMU( I2C_MODE, 0x6B );
void setup()
{
Serial.begin(115200);
delay(1000); //relax...
Serial.println("Processor came out of reset.\n");
//Call .beginCore() to configure the IMU
if ( myIMU.begin() != 0 )
{
Serial.print("Error at beginCore().\n");
}
else
{
Serial.print("\nbeginCore() passed.\n");
}
Hey guys,
figuring the chip. But the library is a bit of.
the tap example is not working. There are used the wrong register.
Here an example how I was able to run the tap function.
`#include "SparkFunLSM6DS3.h"
#include "Wire.h"
LSM6DS3 myIMU( I2C_MODE, 0x6B );
void setup()
{
Serial.begin(115200);
delay(1000); //relax...
Serial.println("Processor came out of reset.\n");
//Call .beginCore() to configure the IMU
if ( myIMU.begin() != 0 )
{
Serial.print("Error at beginCore().\n");
}
else
{
Serial.print("\nbeginCore() passed.\n");
}
//Error accumulation variable
uint8_t errorAccumulator = 0;
uint8_t dataToWrite = 0; //Temporary variable
//Setup the accelerometer******************************
dataToWrite = 0; //Start Fresh!
dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_200Hz;
dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_2g;
dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_416Hz;
// //Now, write the patched together data
errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, dataToWrite);
//Set the ODR bit
errorAccumulator += myIMU.readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C);
dataToWrite &= ~((uint8_t)LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED);
// Enable tap detection on X, Y, Z axis, but do not latch output
errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_TAP_CFG1, 0x8E ); // org 0x0E
// Set tap threshold
// Write 0Ch into TAP_THS_6D
errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_TAP_THS_6D, 0x8C ); // 0x03
// Set Duration, Quiet and Shock time windows
// Write 7Fh into INT_DUR2
errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_INT_DUR2, 0x7F );
// Single & Double tap enabled (SINGLE_DOUBLE_TAP = 1)
// Write 80h into WAKE_UP_THS
errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_WAKE_UP_THS, 0x80 );
// Single tap interrupt driven to INT1 pin -- enable latch
// Write 08h into MD1_CFG
errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_MD1_CFG, 0x08 ); // 0x48
if ( errorAccumulator )
{
Serial.println("Problem configuring the device.");
}
else
{
Serial.println("Device O.K.");
}
}
bool checkForDoubleTap()
{
static unsigned long tapWait; // decay value so double taps wont refire right away
uint8_t reg;
myIMU.readRegister(®, LSM6DS3_ACC_GYRO_TAP_SRC);
if (tapWait < millis()) {
}
return false;
}
void loop()
{
checkForDoubleTap();
}`
The text was updated successfully, but these errors were encountered: