Hi,
I am trying to setup a sparkfun adxl337, I am using the following code but I do not understand the readings I am getting. If i twist the accelerometer so Z is pointing roughly down i get readings X:391 Y: 390 Z:342. If i then make it so Z is pointing roughly upwards i get readings X:440 Y: 441 Z: 511.
I don't understand why all 3 values are changing, surely it should only be the Z axis?
I am also finding that when holding the accelerometer against a surface (still) it sometimes jumps around with values, sometimes it'll settle on EG. 390, then if i do the same experiment again it'll settle on EG. 440. Despite being held in the same position.
I am also finding that when moving the accelerometer as much as i can (flicking it, shaking etc), i am only able to produce values between about 300 and 710 on any of the axes.
I have it connected to 3.3V on my Arduino.
I have tried connecting the AREF pin and using the code 'analogReference(EXTERNAL);' but this just seemed to replicate the problem just with different values.
Thanks very much
// Pin Definitions
#define ADXL335_PIN_XOUT A3
#define ADXL335_PIN_YOUT A5
#define ADXL335_PIN_ZOUT A1
void setup() {
Serial.begin(9800);
}
void loop(){
//analogReference(EXTERNAL);
int rawX = analogRead(ADXL335_PIN_XOUT);
int rawY = analogRead(ADXL335_PIN_YOUT);
int rawZ = analogRead(ADXL335_PIN_ZOUT);
Serial.print("X Raw: "); Serial.print(rawX);
Serial.print(" Y Raw: "); Serial.print(rawY);
Serial.print(" Z Raw: "); Serial.println(rawZ);
delay(100);
}