ADXL335 Accelerometer Sensor working and Arduino Interface

An Accelerometer can be demonstrated as an electronic device used to measure the movement of anybody or a structure. In simple words, it measures the acceleration and vibration of anybody. It can absorb the vibrating waves released by the body and find out the point of orientation of the body. It is capable of sensing the vibrations from lowest frequency to highest frequency. It is widely used in satellites, aircraft for navigation, laptops for safety purposes, etc. In the article, we will learn about the working of the Accelerometer. After that, we also understand how to interface Accelerometer with Arduino.

How does Accelerometer work?

The working of the Accelerometer is based on the electromechanical sensor, which is fabricated for calculating both dynamic and static acceleration. A piezoelectric material is present in these electromechanical sensors, which experience stress due to any acceleration. When anybody or object vibrates or accelerates, this material experiences stress and moves in the direction where the effect of stress due to acceleration is high. Consequently, it starts moving or accelerating in the same phase as the vibration occurs. This acceleration results in the generation of voltage. The amount of voltage helps determine the intensity of vibration in the body. If the voltage generation is high, the object vibrates at a higher intensity and vice versa. Hence, by determining the converting the mechanical energy of the body’s vibration into the electrical energy (voltage), the Accelerometer measures any object’s movement and vibration.

Material Required

ADXL335 Accelerometer1
Arduino UNO1
Jumper WiresAs per requirement

Accelerometer Pinout

Before understanding the actual interface of the Accelerometer with Arduino. Let’s take a look at the pinouts of the Accelerometer:

Pin NameFunction
VCCVCC delivers power to the Accelerometer and gets connected with the 5V in Arduino.
X-OUTIt provides analog voltage in the form of output, and this voltage will remain proportional to the acceleration on X-axis.
Y-OUTIt provides analog voltage in the form of output, and this voltage will remain proportional to the acceleration on Y-axis.
Z-OUTIt provides analog voltage in the form of output, and this voltage will remain proportional to the acceleration on the Z-axis. 
GNDThis pin gets connected with the GND in the Arduino.

Connection with Arduino

Now, let’s understand the wiring of the Accelerometer with the Arduino for understanding its interface. 



const int xInput = A0;
const int yInput = A1;
const int zInput = A2;

// initialize minimum and maximum Raw Ranges for each axis
int RawMin = 0;
int RawMax = 1023;

// Take multiple samples to reduce noise
const int sampleSize = 10;

void setup() 

void loop() 
	//Read raw values
	int xRaw = ReadAxis(xInput);
	int yRaw = ReadAxis(yInput);
	int zRaw = ReadAxis(zInput);

	// Convert raw values to 'milli-Gs"
	long xScaled = map(xRaw, RawMin, RawMax, -3000, 3000);
	long yScaled = map(yRaw, RawMin, RawMax, -3000, 3000);
	long zScaled = map(zRaw, RawMin, RawMax, -3000, 3000);

	// re-scale to fractional Gs
	float xAccel = xScaled / 1000.0;
	float yAccel = yScaled / 1000.0;
	float zAccel = zScaled / 1000.0;

	Serial.print("X, Y, Z  :: ");
	Serial.print(", ");
	Serial.print(", ");
	Serial.print(" :: ");
	Serial.print("G, ");
	Serial.print("G, ");


// Take samples and return the average
int ReadAxis(int axisPin)
	long reading = 0;
	for (int i = 0; i < sampleSize; i++)
	reading += analogRead(axisPin);
	return reading/sampleSize;

Leave a Comment