Adjust analog input range

Dear Arduino User,

Is there a way I can adjust the Analog in range from 0-5 Volt to 0-2.5 Volt? I have a sensor which produces values between 0 and 2.5 and I need arduino to digitize the input with as much resolution as possible.

I understand that I can change the reference voltage, but how?

Thanks, Greg

One possibility is to use an opamp with a voltage gain of 2. You will need an opamp that can work from a single supply (+5v) and can go rail-to-rail. Something like a MAX473 or a TLV2372.

Hook the 2.5V up to AREF, and add this to your code:

ifndef cbi

define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))


ifndef sbi

define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))


and in setup...

cbi(ADMUX, REFS1); //clear REFS1 bit (0) cbi(ADMUX, REFS0); //clear REFS0 bit (0)

Now, 2.5V will be your reference for ADC of 1023. It may be good to put a capacitor on the Aref pin to minimize noise if your voltage is noisy.


Thanks to both or you for the excellent advice!
When I follow up about changing
the AREF, I find this:

Table 74. Voltage Reference Selections for ADC
REFS1 REFS0 Voltage Reference Selection
0 0 AREF, Internal Vref turned off
0 1 AVCC with external capacitor at AREF pin
1 0 Reserved
1 1 Internal 2.56V Voltage Reference with external capacitor at AREF pin

Does that mean if I change the bits to 11 I will get to use the INTERNAL 2.56 V (which would be close enough), and if so what would that code look like?

Thanks, Greg

Like so:

sbi(ADMUX, REFS1); //set REFS1 bit (1) sbi(ADMUX, REFS0); //set REFS0 bit (1)

If I understand the datasheet correctly, in this case you wouldn't want anything connected to the AREF pin.


Dear D. Ok so that's how that code works. It works great, no extra electronics or power supplies!

Thanks so much for you help.