The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. The product measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tiltsensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration.
The user selects the bandwidth of the accelerometer using the CX, CY, and CZ capacitors at the XOUT, YOUT, and ZOUT pins. Bandwidths can be selected to suit the application, with a range of 0.5 Hz to 1600 Hz for X and Y axes, and a range of 0.5 Hz to 550 Hz for the Z axis.
Here is a typical module that makes it easy to work with the ADXL335
Features:
Name: ADXL335 module (triaxial accelerometer analog output)
Model: GY-61
Power supply :3-5v
Analog X, Y, Z three-axis output
Parts List
Schematic
The following layout shows how to wire the ADXL335 module up to a Chipkit Max32
Code
[codesyntax lang=”cpp”]
const int xpin = A0; // x-axis of the accelerometer const int ypin = A1; // y-axis const int zpin = A2; // z-axis void setup() { Serial.begin(9600); } void loop() { int x = analogRead(xpin); //read from xpin delay(1); // int y = analogRead(ypin); //read from ypin delay(1); int z = analogRead(zpin); //read from zpin float zero_G = 512.0; //ADC is 0~1023 the zero g output equal to Vs/2 float scale = 102.3; //ADXL335330 Sensitivity is 330mv/g //330 * 1024/3.3/1000 Serial.print(((float)x - 331.5)/65*9.8); //print x value on serial monitor Serial.print("\t"); Serial.print(((float)y - 329.5)/68.5*9.8); //print y value on serial monitor Serial.print("\t"); Serial.print(((float)z - 340)/68*9.8); //print z value on serial monitor Serial.print("\n"); delay(1000); //wait for 1 second }
[/codesyntax]
Output
Open the serial monitor and you should see something like this
94.61 20.53 9.51
76.21 20.67 9.51
76.06 22.10 16.43
76.67 21.96 16.57
76.67 15.95 24.93
77.72 23.82 16.86
76.67 22.39 2.16
75.61 7.51 17.44
76.82 28.26 25.51
77.72 27.68 7.93
76.21 21.67 29.26
77.72 18.53 27.24
Links
http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL335.pdf