Acceleration Measurement with Accelerometer ADXL335 & Arduino

Acceleration Measurement with Accelerometer ADXL335 & Arduino (Last Updated On: February 22, 2019)

Acceleration Measurement with Accelerometer ADXL335 & Arduino:

In this post we will learn about Acceleration Measurement with Accelerometer & Arduino. We have used ADXL335 3 axis accelerometer for measuring the acceleration in x, y and z axis. The measured acceleration is displayed on 16*2 LCD Display. You can even use ADXL345 Digital Accelerometer with I2C interface.

Here we will be interfacing ADXL335 Accelerometer with Arduino to measure the acceleration in x, y and z axis. But before getting started you can visit our earlier post to learn more about accelerometer.
1. Interface ADXL345 Accelerometer with Arduino & Processing Animation
2. Arduino Earthquake Detector Alarm with Seismic Graph using Accelerometer



Components Required:

1. Arduino UNO Board (Buy Online from Amazon)
2. ADXL335 3 Axis Accelerometer (Buy Online from Amazon)
3. 16×2 LCD Display (Buy Online from Amazon)
4. Breadboard
5. Jumper Wires
6. 5 Volt Power Supply


What is an Accelerometer?

Accelerometers are devices that measure acceleration, which is the rate of change of the velocity of an object. They measure in meters per second squared (m/s2) or in G-forces (g). A single G-force for us here on planet Earth is equivalent to 9.8 m/s2, but this does vary slightly with elevation (and will be a different value on different planets due to variations in gravitational pull). Accelerometers are useful for sensing vibrations in systems or for orientation applications.


ADXL335 3 Axis Accelerometer:

Introduction:

Acceleration Measurement with Accelerometer ADXL335 & Arduino

This Accelerometer module is based on the popular ADXL335 three-axis analog accelerometer IC, which reads off the X, Y and Z acceleration as analog voltages. By measuring the amount of acceleration due to gravity, an accelerometer can figure out the angle it is tilted at with respect to the earth. By sensing the amount of dynamic acceleration, the accelerometer can find out how fast and in what direction the device is moving. Using these two properties, you can make all sorts of cool projects, from musical instruments (imagine playing and having the tilt connected to the distortion level or the pitch-bend) to a velocity monitor on your car (or your children’s car). The accelerometer is very easy interface to an Arduino Micro-controller using 3 analog input pins, and can be used with most other micro controllers, such as the PIC or AVR.



Working of ADXL335 Accelerometer:

The most commonly used device is the piezoelectric accelerometer. As the name suggests, it uses the principle of piezoelectric effect. The device consists of a piezoelectric quartz crystal on which an accelerative force, whose value is to be measured, is applied.

Acceleration Measurement with Accelerometer ADXL335 & Arduino

Due to the special self-generating property, the crystal produces a voltage that is proportional to the accelerative force. The working and the basic arrangement is shown in the figure below.


Circuit Diagram & Connection for Acceleration Measurement:

Here is a circuit diagram for interfacing ADXL335 3 Axis Accelerometer with Arduino for measuring Acceleration. Assemble the circuit as shown in the figure below.

Circuit diagram for Acceleration Measurement with Accelerometer ADXL335 & Arduino



Source Code/ Programs:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int Xread;
int Xrest;

int Yread;
int Yrest;

int Zread;
int Zrest;

double Gx;
double Gy;
double Gz;

int xpin = 0;
int ypin = 1;
int zpin = 2;

int t1;

void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
digitalWrite(13,HIGH);
delay(1000);
Xrest=analogRead(xpin);
Serial.print(Xrest);
Yrest=analogRead(ypin);
Serial.print(Yrest);
Zrest=analogRead(zpin);
Serial.print(Zrest);
digitalWrite(13,LOW);
}
void loop()
{
Serial.print("Time ");
t1=millis();
Serial.println(t1*0.001);

Xread = analogRead(xpin)-Xrest;
Yread=analogRead(ypin)-Yrest;
Zread=analogRead(zpin)-Zrest;

Gx=Xread/67.584;
Gy=Yread/67.584;
Gz=Zread/67.584;

Serial.print("Acceleration X :");
Serial.print(Gx);
Serial.print("Acceleration Y :");
Serial.print(Gy);
Serial.print("Acceleration Z :");
Serial.print(Gz);
Serial.print("\n");

lcd.setCursor(0, 0);
lcd.print("gx:");
lcd.print(Gx);
lcd.setCursor(8, 0);
lcd.print("gy:");
lcd.print(Gy);
lcd.setCursor(0, 1);
lcd.print("gz:");
lcd.print(Gz);
delay(1000);
lcd.clear();
}

Video Tutorial & Explanation:

Recommended For You

Ask A Question .......

Close