ADXL345 Accelerometer sensor error

I have an accelerometer connected to an Arduino Uno board. but showing me an error can anybody help me out?

#include <SoftwareSerial.h>

float distance = 0;
unsigned long startTime;
void setup()
{
//....
Serial.begin(9600);
startTime = millis(); // will store time of first execution of program.
}

void loop()
{

float x = getX(); // save data of 3 axis from ADXL345(first you have to be able to get data from ADXL345)
float y = getY();
float z = getZ();

float accel = sqrt(x * x + y * y + z * z); // add as a vector to get cummulative acceleration.
unsigned long currentTime = millis();

//calculating distance using distance formula

distance = 0.5 * accel * (currentTime - startTime) * (currentTime - startTime) / 1e6; // 1e6 is correction to convert millis to seconds
startTime = currentTime; // remember time for next cycle

Serial.println(distance, 5); // displaying distance calculated
}


/Users/ahmedalbuainin/Documents/Arduino/ADXL345/ADXL345.ino: In function 'void loop()':
ADXL345:16: error: 'getX' was not declared in this scope
float x = getX(); // save data of 3 axis from ADXL345(first you have to be able to get data from ADXL345)
^
ADXL345:17: error: 'getY' was not declared in this scope
float y = getY();
^
ADXL345:18: error: 'getZ' was not declared in this scope
float z = getZ();
^
exit status 1
'getX' was not declared in this scope

Please use [ code ] tags next time. The forum software eats some of your code and turns it into smileys if you don't.

It is saying that you never defined the getX() function. Is this function supposed to be in a library? You didn't #include any libraries.

There should be a lot of examples online for this sensor. Search around some more.

Use code tags and do not double post.

Check out the way I calculated the distance traveled by an elevator using the ADXL345. It's not the most accurate or even easy, but I go through the whole process on my blog:

Let me know if you have any questions!