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 the 16*2 LCD Display. You can even use ADXL345 Digital Accelerometer with the 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:
- Arduino UNO Board
- ADXL335 3 Axis Accelerometer
- 16×2 LCD Display
- Breadboard
- Jumper Wires
- 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:
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 to interface to an Arduino Micro-controller using 3 analog input pins and can be used with most other microcontrollers, 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.
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.
Source Code/ Programs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#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(); } |
4 Comments
can you explain more about the variation ?
from where did you get the value 67.584?
hi how you find the value 67.584?
can i display this on TFT using a bubble