I bought an ADXL321, +-18g dual axis accelerometer, from the red box company. They sent me the wrong part. Now the right part came in a week later and it's not doing what it's supposed to do. Maybe I'm completely wrong but I expect 512 for x and y axes output since I lay it flat but I got 743ish, with 5V supply. Tilting the accelerometer will get as big as 756 or as small as 731. This has +-18g so 512 levels correspond to 18g, making 28 levels per g. My tilting should create exactly 1g from laying flat so should increase 28 instead of 14ish. Any idea what could have gone wrong?
Datasheet here:
http://www.analog.com/static/imported-files/data_sheets/ADXL321.pdfCode:
void setup()
{
Serial.begin(115200);
}
void loop()
{
int temp;
lcd.setCursor(0,0);
temp=analogRead(0);
Serial.print(temp);
Serial.println(" ");
lcd.setCursor(0,1);
temp=analogRead(1);
Serial.print(temp);
Serial.println(" ");
delay(500);
}
I simply has nothing on the arduino except for the accelerometer, powered by the 5V and gnd pins and sensed by analog 0 and 1 for x and y axes.
