adxl335 acceleration sensor

i am trying to write a code for acceleration meter. i am reading the raw value from sensor in x,y and z direction and i want to combine all these information to get the single value of acceleration. i am new in programming i have written a code but not getting the right result. i am getting the negative and positive value at serial monitor and also the acceleration change really quickly what a small movement of sensor. can someone help me out with this.
Thanks in advance. Below i paste the code
Zahid

const int analogInPin1 = A0;
const int analogInPin2 = A1;
const int analogInPin3 = A2;
int last_Val = 0;
int new_Val = 0;

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// read the analog in value:

int _x = analogRead(analogInPin1);
int _y = analogRead(analogInPin2);
int _z = analogRead(analogInPin3);

float _Acc = sqrt(_x^2+_y^2+_z^2);

last_Val = new_Val;
new_Val = _Acc;
float diff = new_Val-last_Val;

Serial.println(diff);
delay(1000);
}

Please use code tags when posting code.

"^" is the operator for XOR (exclusive OR). Try multiply with float variables instead:

float x = analogRead(analogInPin1);
float y = analogRead(analogInPin2);
float z = analogRead(analogInPin3);
float Acc = sqrt(x*x + y*y + z*z);

You will also need to subtract the zero bias from the analog input readings in order to make any sense of the result.

I recommend to avoid using the underscore character in variable names.

jremington:
Please use code tags when posting code.

"^" is the operator for XOR (exclusive OR). Try multiply with float variables instead:

float x = analogRead(analogInPin1);

float y = analogRead(analogInPin2);
float z = analogRead(analogInPin3);
float Acc = sqrt(xx + yy + z*z);




You will also need to **subtract the zero bias** from the analog input readings in order to make any sense of the result.

I recommend to avoid using the underscore character in variable names.

yes i have changed that later on the XOR symbol and used the multiply sign instead of that. can you please explain me what does you mean by subtract the zero bias and how can i do that. That will be a great help. Thanks a lot in advance

Look at the number that the program outputs for an accelerometer axis that is perfectly horizontal and still.

That is the zero bias value, corresponding to zero acceleration. Subtract that value from further readings on that axis.

There is one value for each axis, but they are not necessarily different.