Atmega324P

\$8.50
Qty:

USB AVR Programmer

\$9.95
Qty:

\$4.90
Qty:

18.432 MHz Crystal Oscillator 18pf 30ppm

\$0.94
Qty:

22 pF Multilayer Ceramic Capacitor

\$0.43
Qty:

16 MHz Crystal Oscillator 20 pF Through Hole

\$0.75
Qty:

SPDT Slide Switch 3 pin 30V

\$1.49
Qty:

USB to Serial Converter

\$10.95
Qty:

\$3.80
Qty:

Quad Buffer Line Driver (Through Hole)

\$0.69
Qty:

### Connecting an Accelerometer to the ADC (Analog to Digital Converter)

Let's go down this metal street in Breadboardville and meet this tipsy Mr. Gravity, shall we? While we're there, we will poke and prood him to see how he reacts. This is ok since we need to determine his sensitivity and what type of currency he will give us. I gotta watch out with these tipsy gravity folks. They may provide you with analog voltage currency, or currency that involves time! Mr. Gravity that gives time relative currency, then he is better suited to interact with Mrs. PWM. Remember her? She's the one with the stopwatch.

If Mr. Gravity is the type to provide us with the voltage currency, he is perfect for the ADC. The really sick Mr. Gravities can also have multiple personalities. Which ever way you push Mr. Gravity, he could regurgitate his voltage in one of three of his output ports. Actually, he is constantly regurgitating. At full stance (no tilt), he is at about mid level regurgitation with his voltage currency. If pushed him forward, he starts to regurgitate the currency proportional to the amount of force on his back. This force is actually measured in G's. Just to get a good reference, one G is the force of gravity at a standstill and with the average amount of earth's crust in-tact (yep, there is less gravity if there are large holes below you, but that get's into heavy physics, so I will leave that alone for now!).

Back to Mr. Gravity. guess what happens if you push him backward. You are right, he regurgitates less relative to the gravity. However! If you push him hard, he feels that "force" (in g's, remember) and he will regurgitate in proportion to the push of acceleration.

The program for the ADC is pretty basic. All we are doing is changing the reference voltage. Instead of using the AVCC pin to determine the top voltage for the ADC, we are using an internal reference voltage (a voltage that the microcontroller "King Core" has devised himself). Why are we changing this voltage reference? Why isn't the AVCC good enough. Well, we actually could use the AVCC, but the resoltion of the ADC result would be reduced. In the case of the AVCC reference voltage, the microcontroller thinks that you are going to send it a sensor that provides a voltage all the way up to 5v. Mr. Gravity is only regurgitating up to about 2.4 volts, so the voltage from 2.4 to 5v is essentially waisted. so we want to use a voltage reference closer to the top voltage that Mr. Gravity will provide.

To set this internal voltage, all we do is set REFS0 and REFS1. It's as easy as that.

Here is what the program may look like:

#include <avr/io.h>
#include <avr/interrupt.h>
#include "MrLCD.h"
int main(void)
{
InitializeMrLCD();

sei();