how to use accelerometer using atmega16?

I want to use accelerometer using my atmega16, but I have no idea about it. I only know that I have to use the ADC ports... help please

18 answers
sort by: active | newest | oldest
Jun 22, 2012. 5:21 AMgmoon says:
Don't want to steal Steve's thunder, but I made a wireless accelerometer joystick. The transmitter uses an ADXL330 and an ATmega8, among the components. The ADXL330 is analog output also, and the ADC code would be virtually identical for an ATmega16.

Here's link to the details page; there you'll find a source zip.

It's been 5 or 6 years, so my AVR ADC coding skill are a little rusty, but between the source and the datasheet you should be on your way...
Jun 21, 2012. 6:57 AMsteveastrouk says:
What programming environment are you using ?
Have you read the data sheet ? These things are very, very easy to use.

Steve
Jun 21, 2012. 12:59 PMsteveastrouk says:
Can you program ?
Jun 21, 2012. 2:03 PMsteveastrouk says:
Do you want to do this yourself, or use one of the libraries ?
Jun 21, 2012. 3:16 PMsteveastrouk says:
Start with another datasheet !

http://www.atmel.com/Images/doc2466.pdf

P204

Here you'll find the control registers for the ADC described, the multiple operating modes, and how to start them.

You are programming "on the metal", so you have to know at the very lowest level how the processor works.

Steve
Jun 22, 2012. 6:16 AMsteveastrouk says:
OK then,
Lets walk through the steps you need.

1.) Config: Decide on sampling rate and type

2.) Using Interrupts ?

3.) Reading data out: how to avoid atomicity issues.

Jun 22, 2012. 1:11 PMsteveastrouk says:
Forget the accelerometer bit - all you're doing is reading three voltages.
Gmoon's code's a good place to start.
Jun 20, 2012. 2:29 PMsteveastrouk says:
WHICH accelerometer ? Most actually have digital outputs.
Jun 21, 2012. 2:16 AMsteveastrouk says:
Device NAME and NUMBER

Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!