I'm using an ATMEG328P (the IC is programmed with the Pro Mini boot loader) ... and everything seems to be working fine ... except, all my ADCs are reading 1023 (A0, A1, A2, A3, A6 and A7). I'm using A4 and A5 for I2C.
A6 is the only one that is being used and the input voltage is about 2.5V, yet ... A6 reads 1023. All the others are floating and the read values for these are not even "dancing" around as one might expect if nothing is connected ... they simply read 1023 (all the time).
Can anyone think of anything that might give rise to that behavior?
A6 might read 1023 if you have accidentally chosen this code in your sketch: analogReference(INTERNAL);. If so, change it to: analogReference(DEFAULT); or delete it.
@GolamMostafa
Thank you. I'm not using that line of code.
@jremington
Thank you. It doesn't matter what voltage level is on the Ax pins, the ADC reports 1023 (I'm using the serial monitor to observe that). I'm not using pinMode on any of the Ax pins.
TimHo:
A6 is the only one that is being used and the input voltage is about 2.5V, yet ... A6 reads 1023. All the others are floating and the read values for these are not even "dancing" around as one might expect if nothing is connected ... they simply read 1023 (all the time).
The "AREF" pin is tied to ground via a 0.1uF cap.
Time to measure the voltage on the Aref pin with a DMM.
If Aref is less than the voltage on A6, then the A/D reports 1023.
Pointless to measure floating analogue pins.
They just follow the last measurement on A6 (internal muxer cross-talk).
Leo..
Thank you for all of your responses ... I think it's my fault ... please see if you agree. I was harboring the belief that AREF was an input-only pin ... so I paid no attention to and failed to mention (until now) that before I connected a 0.1uF capacitor between AREF and GND ... I had connected a zero Ohm resistor between AREF and GND. Eventually (many minutes), I noticed my mistake and corrected the issue.
TimHo:
I was harboring the belief that AREF was an input-only pin ... so I paid no attention to and failed to mention (until now) that before I connected a 0.1uF capacitor between AREF and GND ... I had connected a zero Ohm resistor between AREF and GND.
The following diagram depicts the role of the AREF-pin of the MCU. This line/pin has two purposes: (1) It is used to connect 100nF filter capacitor when 5V or Internal 1.1V is used for the VREF pin of the ADC. (2) It is used to feed external voltage (1.1V - 5V) for the VREF pin of the ADC when 5V or Internal 1.1V is not used.