ADXL335 accelerometer extremley low resolution

Hi,

I just set up the ADXL335 accelerometer and I am wondering wondering why the raw analog input from this is always an integer?

I tried changing it to a float but I always get whole numbers like 410.00, 409 ect.

The integer values it gives have so low resolution that there is only an input change of 2 over about 30 degrees.

For example when the sensor is at 180deg A0 = 410, when it is at 150deg A0 = 408.

This is a 15% per step.

Obviously I tried scaling it down to voltage but if the raw input has no resolution scaling it doesn't help.

Is it normally that inaccurate or do I have a dud sensor?

This is how I am collecting the data:

const float xpin = A0;

void setup() {
  // Start the serial 
  Serial.begin(9600);

}

void loop() {
  
  // Read the raw x value
  float rawX = analogRead(xpin);
  delay(1);

  // Print the raw x value to serial monitor
  Serial.print(rawX);
  Serial.print("\n");
  
}

Thanks for your help

The output of analogRead() is an integer.

What breakout board are you using?
How is the ADXL335 powered?
Do you have the grounds connected?

When everything is working, the best test is to point one axis of the accelerometer up, note the output reading for that axis, then point it down and note the output reading. The difference is 2 g.

const float xpin = A0;

Pin numbers are best expressed in integer data types.

...gives new meaning to "floating input"!