You are on page 1of 3

Accelerometer interfacing manual

What is an accelerometer?
An accelerometer is an electromechanical device that will measure acceleration forces. These
forces may be static, like the constant force of gravity pulling at your feet, or they could be
dynamic - caused by moving or vibrating the accelerometer.

How does an accelerometer works?


There are many different ways to make an accelerometer! Some accelerometers use the
piezoelectric effect - they contain microscopic crystal structures that get stressed by accelerative
forces, which cause a voltage to be generated. Another way to do it is by sensing changes in
capacitance. If you have two microstructures next to each other, they have a certain capacitance
between them. If an accelerative force moves one of the structures, then the capacitance will
change. Add some circuitry to convert from capacitance to voltage, and you will get an
accelerometer. There are even more methods, including use of the piezoresistive effect, hot air
bubbles, and light.

It gives six different values in the corresponding tilts like x+, x-, y+, y-, z+, z-;

Its value varies from 1.2v to 1.9v.

If you tilt the accelerometer in x+ then its value will increase upto 1.9v, if you tilt the
accelerometer in x- then its value decreases upto 1.2v. Similarly y-axis and z-axis value also
varies from 1.2v to 1.9v.
Connection details:-
1. Connect 5v supply to the vcc of accelerometer
2. Connect ground to gnd of the accelerometer
3. Connect pin X of the accelerometer to ADC0
4. Connect pin Y to ADC1.
5. Do not connect the ST pin with anyone.

With moving accelerometer in x and y direction, the output of PORTC varies.Program for the
same has been mentioned below.

Sample program to interface accelerometer with Atmega 16

#include <avr/io.h>
#include <util/delay.h>
unsigned char a,b,c;

void adc_init()
{
ADCSRA=0xE5;
}

void adc_getvalue()
{
ADMUX=0x60;
_delay_ms(1);
a=ADCH;
ADMUX=0x61;
_delay_ms(1);
b=ADCH;
}
void main()
{
DDRC=0XFF;
DDRA=0x00;
adc_init();
while(1)
{
adc_getvalue();
if(a>100)
PORTC=0b00001010;
else if(a<80)
PORTC=0b00000101;
else if(b>100)
PORTC=0b00001001;
else if(b<80)
PORTC=0b00000110;
else
PORTC=0b11111111;
}
}

You might also like