Max 3,3V analog input

Hi!

Im using a accelerometer that runs at 3,3V.
My arduino mega whants 5V to get all the benefit of 10bit analog input.

Now I get a max analog read value of 680 and I need it to be 1023.

Thanks!
/Anders

You can use an external reference voltage of 3.3V. This will give you the full 10 bit resolution of the ADC at 3.3V

Search the forum for analog + vref to find info on how to do it.

Can't you just power the accelerometer from the 3V pin on the Arduino instead of the 5V one, and use 5V elsewhere in the circuit?

No that wont help. If you use the built in 5V ref. voltage and apply a max of 3.3V to an analog pin you wont get the full 10 resolution frm the ADC

Thanks!
I connect the 3,3V power supply to the AREF pin.

And use this in my code:
analogReference(EXTERNAL);

It works like a charm!

/Anders