The only electronic website that replies to every comment, and addresses all circuit related issues.

## How to Interface Accelerometer ADXL335 with Arduino

In this post, we are going to see how to use an accelerometer with arduino and extract useful readings, which will be printed on serial monitor of IDE. We will also be exploring how accelerometer works in a nutshell and its applications.

Accelerometer is an electromechanical device, which is used to detect acceleration. The acceleration can be a static such as gravitational force, while dynamic acceleration can be sudden movement or vibration.

The accelerometer is partially mechanical device because of its internal mechanism. It has moving plates arranged like capacitor, these plates can move freely when it is subjected to external force.

The moving plates are separated few micrometers between them and it is extremely tiny and packed into IC form which is few millimeter in size.

The plates which can move freely have microscopic weight attached to it, which is made from silicon. The microscopic weight absorbs any external impact and applies it to moving plates.

When moving plates are subjected to moments it changes its capacitance, which can be detected by external circuits.

Typical accelerometer module:

Accelerometer can be single, double or triple axis; here we are using triple axis accelerometer which can detect acceleration in 3 axes i.e. X, Y and Z. This means it has three such moving capacitors placed in X, Y and Z directions fabricated into single IC module.

If you want to know more about accelerometers, you can check out this link which explains how accelerometer works.

The accelerometer used in this project has analogue voltage output with respect to external acceleration. To use it on digital circuits, we need to convert the analogue voltage into digital. The process for converting analogue to digital conversion can be easily accomplished by arduino.

The circuit:

The discussed Arduino accelerometer circuit is very simple as we are only going to extract readings from the accelerometer. The accelerometer has 5 terminals Vcc, GND, X, Y and Z terminals.

The X, Y and Z axes terminals are connected to A2, A1 and A0 terminals of arduino respectively.

The accelerometer can be powered from 3.3V port on arduino. Please take at-most care while powering from external power supplies for projects, 5V can easily damage the accelerometer, it has absolute maximum voltage of 3.6V.

Program:

//---------------Program developed by R.Girish-------------------//
const int xpin = A2;
const int ypin = A1;
const int zpin = A0;
void setup()
{Serial.begin(9600);
}
void loop()
{
Serial.print("X=");
Serial.print("\t");
Serial.print("Y=");
Serial.print("\t");
Serial.print("Z=");
Serial.println();
delay(500);
}
//---------------Program developed by R.Girish-------------------//

The program is very simple; we are assigning three of the analogue pins for input from accelerometer and starting the serial monitor and set its bit rate 9600. Using Serial.print(); we are printing the accelerometer readings on the serial monitor.

OUTPUT:

What we can infer from the serial monitor is the voltage level from the accelerometer’s three different axes. When it is subjected external force or tilt it gets reflected in the serial monitor.

We can program the arduino trigger some external peripherals such as relay or LED or motor, when the acceleration or tilt is subject to go beyond pre-determined threshold but, it is subject of an another article.

Applications of accelerometers:

Accelerometer has wide spectrum of applications from smartphone to aircraft.

• The accelerometers are boon for smartphone, have you ever wondered how your screen change its orientation from landscape to portrait and vice versa or the guy in ‘Temple run’ moves left and right when you tilt for phone? Well it’s all the wonder of accelerometer.

• Accelerometer is used in aircraft to measure several parameters to stabilize the fight.

• It is used in digital cameras for optical image stabilization.

• It is used in electronically stabilized tripods for photography professionals.

The above are mere fraction of the application of accelerometer. Now you know what an accelerometer is, how to use with arduino and where it is used.