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