I'm using ADXL345 to detect free fall. I found a library in github with an example of free fall sketch. but is showing me this error: no matching function for call to 'ADXL345::ADXL345()'
#include <Wire.h>
#include <ADXL345.h>
ADXL345 accelerometer;
void setup(void)
{
Serial.begin(9600);
// Initialize ADXL345
Serial.println("Initialize L3G4200D");
if (!accelerometer.begin())
{
Serial.println("Could not find a valid ADXL345 sensor, check wiring!");
delay(500);
}
// Values for Free Fall detection
accelerometer.setFreeFallThreshold(0.35); // Recommended 0.3 -0.6 g
accelerometer.setFreeFallDuration(0.1); // Recommended 0.1 s
// Select INT 1 for get activities
accelerometer.useInterrupt(ADXL345_INT1);
// Check settings
checkSetup();
}
void checkSetup()
{
Serial.print("Free Fall Threshold = "); Serial.println(accelerometer.getFreeFallThreshold());
Serial.print("Free Fall Duration = "); Serial.println(accelerometer.getFreeFallDuration());
}
void loop(void)
{
delay(50);
// Read values for activities
Vector norm = accelerometer.readNormalize();
// Read activities
Activites activ = accelerometer.readActivites();
if (activ.isFreeFall)
{
Serial.println("Free Fall Detected!");
}
}
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags: [code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.
Post a link to where you got the library from. Please use the chain links icon on the toolbar to make it clickable.
When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.
The full output might contain information that will give me a clue to what's going on.
The library you linked to does not have a src folder. Instead the source files are located in the root of the library folder.
So you have two choices:
Modify your code to be compatible with the library you are using.
Install the library your code is written for. Note that you will need to delete C:\Users\Navaneeth\Documents\Arduino\libraries\ADXL345 so that the Arduino IDE will include the ADXL345.h file from the Arduino-ADXL345 library.