It is common knowledge is that analogRead () function converts 0 to 5 volt to 0 to 1023 range. But I think it is valid only when the micro controller is powered by 5V regulated voltage. This will not be valid if the micro controller is powered by different voltage. Suppose, if I power a stand alone AtMega328 with 3v, then the analogRead() will actually convert 0 to 3 volt to 0 to 1023. Is my understanding correct? Or a stand alone AtMega328 can read between 0 to 5V regardless of the operating voltage?
It is common knowledge is that analogRead () function converts 0 to 5 volt to 0 to 1023 range
It is?
It converts voltages between 0 and whatever is connected to the analogue reference input (minus one count) into the range 0 . . . 1023.
Yes, as AWOL replied,
it will oscillate the pointer between your Lower Ref. voltage and the VCC i.e the higher one
i.e. whatever you apply at pins 20 and 22 of atmega328. Pin 21 is for setting AREF for you readings.
consider giving a look at the pinout again and you will see that the controller's Vcc, Gnd and ADC unit's VCC, Gnd are given on different pins. They could have saved two pins otherwise and we would have been blessed with two more GPIOs
![]()