Hi, folks.

I am curious about a detail of AD converters in Arduino processors.

On a UNO or NANO, the ATmega328p has a 10-bit AD converter, so it can return unsigned integer values from 0 (representing an input of 0V) to 1023 (representing an input of …, what exactly?)

I don't really know how the innards of an AD converter work. Normally, Arduino developers just use the power-supply voltage (5.0 V on UNO or NANO) as the AD reference voltage.

So does an AD value of 1023 actually represent * EXACTLY* the full reference voltage (e.g.

*5.0V on UNO or NANO)? Or does 1023 actually represent*

**EXACTLY***the reference voltage (e.g.*

**JUST UNDER***5.0V; 4.9951171875V, to be exact ), and the*

**JUST UNDER***full reference voltage (5.0V) would be represented by the (theoretical, but unavailable) value of 1024?*

**EXACT**In sketches that convert AD inputs to actual voltages, I have seen different people use either 1023 or 1024 as the divisor when calculating the voltage. I.e. either (assuming the reference is 5.0V):

`float Vx = 5.0*(((float)ADvalue)/1023.0)`

or

`float Vx = 5.0*(((float)ADvalue)/1024.0)`

Which of the above is the more correct calculation?

(Note: I use 1023 and 1024 above, assuming 10-bit AD converters. I know that some boards have 12-bit converters so, for those cases, substitute 4095 and 4096. )

I know that it does not really make any practical difference "for government work," but curious (and pedantic) minds (at least this one ) want to know!

BTW (and unrelated to the above, but sort of related to AD converters ) I once read that reading in an AD converter value from an unconnected (i.e. open) AD pin, makes a good source of randomness for seeding the Arduino random number generator. Is that good advice?

Thanks and best regards,

DuinoSoar.