Hello,
I have this adxl345 accelerometer, I have all the wires hooked up correctly to an arduino UNO, but when I to upload the demo adxl example it gives me an error saying that a function doesn't work.
This is the demo code.
(yes I have installed both libraries)
// Author: Frankie.Chu
// Date: Jan 11,2013
// Version: v1.0
// by www.seeedstudio.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
/*******************************************************************************/
#include <Wire.h>
#include <ADXL345.h>
ADXL345 adxl; //variable adxl is an instance of the ADXL345 library
void setup(){
Serial.begin(9600);
adxl.powerOn();
//set activity/ inactivity thresholds (0-255)
adxl.setActivityThreshold(75); //62.5mg per increment
adxl.setInactivityThreshold(75); //62.5mg per increment
adxl.setTimeInactivity(10); // how many seconds of no activity is inactive?
//look of activity movement on this axes - 1 == on; 0 == off
adxl.setActivityX(1);
adxl.setActivityY(1);
adxl.setActivityZ(1);
//look of inactivity movement on this axes - 1 == on; 0 == off
adxl.setInactivityX(1);
adxl.setInactivityY(1);
adxl.setInactivityZ(1);
//look of tap movement on this axes - 1 == on; 0 == off
adxl.setTapDetectionOnX(0);
adxl.setTapDetectionOnY(0);
adxl.setTapDetectionOnZ(1);
//set values for what is a tap, and what is a double tap (0-255)
adxl.setTapThreshold(50); //62.5mg per increment
adxl.setTapDuration(15); //625us per increment
adxl.setDoubleTapLatency(80); //1.25ms per increment
adxl.setDoubleTapWindow(200); //1.25ms per increment
//set values for what is considered freefall (0-255)
adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment
adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment
//setting all interrupts to take place on int pin 1
//I had issues with int pin 2, was unable to reset it
adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT, ADXL345_INT1_PIN );
adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT, ADXL345_INT1_PIN );
adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT, ADXL345_INT1_PIN );
adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT, ADXL345_INT1_PIN );
adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT, ADXL345_INT1_PIN );
//register interrupt actions - 1 == on; 0 == off
adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1);
adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1);
adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT, 1);
adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT, 1);
adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 1);
}
void loop(){
//Boring accelerometer stuff
int x,y,z;
adxl.readXYZ(&x, &y, &z); //read the accelerometer values and store them in variables x,y,z
// Output x,y,z values
Serial.print("values of X , Y , Z: ");
Serial.print(x);
Serial.print(" , ");
Serial.print(y);
Serial.print(" , ");
Serial.println(z);
double xyz[3];
double ax,ay,az;
adxl.getAcceleration(xyz);
ax = xyz[0];
ay = xyz[1];
az = xyz[2];
Serial.print("X=");
Serial.print(ax);
Serial.println(" g");
Serial.print("Y=");
Serial.print(ay);
Serial.println(" g");
Serial.print("Z=");
Serial.print(az);
Serial.println(" g");
Serial.println("**********************");
delay(500);
}
Here are there errors i receive:
Multiple libraries were found for "ADXL345.h"
Used: Documents/Arduino/libraries/ADXL345
Not used: Documents/Arduino/libraries/Accelerometer_ADXL345-master
ADXL345_demo_code:57:8: error: 'class ADXL345' has no member named 'setTapDetectionOnZ'
adxl.setTapDetectionOnZ(1);
^
ADXL345_demo_code:60:8: error: 'class ADXL345' has no member named 'setTapThreshold'
adxl.setTapThreshold(50); //62.5mg per increment
^
ADXL345_demo_code:61:8: error: 'class ADXL345' has no member named 'setTapDuration'
adxl.setTapDuration(15); //625us per increment
^
ADXL345_demo_code:62:8: error: 'class ADXL345' has no member named 'setDoubleTapLatency'
adxl.setDoubleTapLatency(80); //1.25ms per increment
^
ADXL345_demo_code:63:8: error: 'class ADXL345' has no member named 'setDoubleTapWindow'
adxl.setDoubleTapWindow(200); //1.25ms per increment
^
ADXL345_demo_code:66:8: error: 'class ADXL345' has no member named 'setFreeFallThreshold'
adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment
^
ADXL345_demo_code:67:8: error: 'class ADXL345' has no member named 'setFreeFallDuration'
adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment
no matching function for call to 'ADXL345::ADXL345()'
I had to cut a lot of the errors because if not I exceed the 9000 character limit.
but most of them are similar to each other, just that it cannot find the member or function.
Note that it says "no matching function for call to 'ADXL345::ADXL345()'".
the weird thing is I tried this on a school windows computer and that worked perfectly sending all the values from the adxl345 to the serial.
is this problem just for people with macs? or is there another problem somewhere?
The setup is identical on both computers, the wiring, the code, the libraries.
Thank you for your time.