0% found this document useful (0 votes)
228 views4 pages

ADXL335 Accelerometer Sensor - How To Use It

The document describes the ADXL335 accelerometer sensor. It operates using the piezoelectric effect, producing electric current when a ball inside touches walls due to gravitational force tilting the sensor. It can detect acceleration in three axes. The sensor is compact and can be used in motion detection projects, robots, phones and watches to detect orientation and movement. Sample Arduino code is provided to read acceleration values from the sensor pins and output them to the serial monitor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
228 views4 pages

ADXL335 Accelerometer Sensor - How To Use It

The document describes the ADXL335 accelerometer sensor. It operates using the piezoelectric effect, producing electric current when a ball inside touches walls due to gravitational force tilting the sensor. It can detect acceleration in three axes. The sensor is compact and can be used in motion detection projects, robots, phones and watches to detect orientation and movement. Sample Arduino code is provided to read acceleration values from the sensor pins and output them to the serial monitor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ADXL335 Accelerometer Sensor - How to Use it?

invent.module143.com/adxl335-accelerometer-sensor-how-to-use-it/

August 19, 2017

ADXL335 is accelerometer sensor which works on the principle of Piezoelectric effect.


whenever we will tilt the sensor the ball is supposed to move in that direction
because of Gravitational force. The walls are made of Piezoelectric elements. So,
every time ball is touching the wall an electric current will be produced which will be
interpreted in the form of values in any 3D space. ADXl335 is a triple axis
accelerometer i.e. it will give 3 values in output. BW is adjustable as it has single
capacitor per axis. Analog interfacing is done for communicating with other devices
like Arduino.

Where to use?
We can use this compact device in any motion detection oriented projects, gesture
control robots, smart phones, smart watches etc.

Application:
http://invent.module143.com/arduino-gesture-robot-using-adxl335/

http://invent.module143.com/earthquake-detector-using-arduino/

Project for Reference:

1/4
Code:
Arduino

2/4
1 const int xpin = A1; // x-axis of the accelerometer
2 const int ypin = A2; // y-axis
3 const int zpin = A3; // z-axis (only on 3-axis models)
4 //
5 int sampleDelay = 500; //number of milliseconds between readings
6 void setup()
7 {
8 // initialize the serial communications:
9 Serial.begin(9600);
10 //
11 //Make sure the analog-to-digital converter takes its reference voltage
12 from
13 // the AREF pin
14 pinMode(xpin, INPUT);
15 pinMode(ypin, INPUT);
16 pinMode(zpin, INPUT);
17 }
18 void loop()
19 {
20 int x = analogRead(xpin);
21 //
22 //add a small delay between pin readings. I read that you should
23 //do this but haven't tested the importance
24 delay(1);
25 //
26 int y = analogRead(ypin);
27 //
28 //add a small delay between pin readings. I read that you should
29 //do this but haven't tested the importance
30 delay(1);
31 //
32 int z = analogRead(zpin);
33 //
34 //zero_G is the reading we expect from the sensor when it detects
35 //no acceleration. Subtract this value from the sensor reading to
36 //get a shifted sensor reading.
37 float zero_G = 512.0;
38 //
39 //scale is the number of units we expect the sensor reading to
40 //change when the acceleration along an axis changes by 1G.
41 //Divide the shifted sensor reading by scale to get acceleration in Gs.
42 float scale = 102.3;
43 //
44 Serial.print(((float)x - zero_G)/scale);
45 Serial.print("\t");
46 //
47 Serial.print(((float)y - zero_G)/scale);
48 Serial.print("\t");
49 //
50 Serial.print(((float)z - zero_G)/scale);
51 Serial.print("\n");
52 //
53 // delay before next reading:
54 delay(sampleDelay);
}

3/4
Serial Monitor Output:

4/4

You might also like