# how to detect up down and left right rotation of Adxl335 accelerometer

hi. I am new to work with arduino uno and Analog Adxl335 accelerometer. i am developing an application to detect accelerometer [up down and left right] tilt. please can you help me

Front-Back tilt is called "Pitch".
Left-Right tilt is called "Roll".

This tutorial explains how to measure them:
http://physics.rutgers.edu/~aatish/teach/srr/workshop3.pdf

There are lots of other examples. Google will let you find lots of other examples.

how can i put all together this code into arduino, bcz it is step by step. and a code given in processing language is not working well. and nothing is shown when i run it in processing software.

``````const int XPin = A0;
const int YPin = A1;
const int ZPin = A2;

// Zero offsets: Average of max and min values
const int XZero = 512;
const int YZero = 512;
const int ZZero = 512;

void setup() {Serial.begin(19200);}
void loop() {
long XAcc = analogRead(XPin) - XZero;
long YAcc = analogRead(YPin) - YZero;
long ZAcc = analogRead(ZPin) - ZZero;

// apply trigonometry to get the pitch and roll:
float pitch = atan(xAcc/sqrt(YAcc*YAcc + ZAcc*ZAcc));
float roll = atan(YAcc/sqrt(XAcc* XAcc + ZAcc* ZAcc));

// Print the values (in Radians)
Serial.print(pitch); Serial.print(","); Serial.println(roll);

delay(1000);
}
``````

sir, how can i connect 2 ADXL335 accelerometers with arduino, because i want to detect human activities such as, sitting standing and walking. Any one can help me