AnalogRead() returns same value for all analog pins

I have an Arduino Nano. No pins have connections except for two, the 5V pin connects directly to any one of the analog pins, A0-A7, through a jumper wire. In my loop, I use AnalogRead() to read the values of A0 through A7. I print() these values to the Serial Monitor. When I disconnect the jumper, all three values read about 170. When I attach the jumper from 5V to any of the seven pins (A0-A7), then all 7 values (A0-A7) jump up to over 900. But I do notice that the pin which has the jumper has a value of 1023.

I would have expected this to happen only to the pin that I connected the jumper to.

Another thing that is strange is that when connecting the 5V to pin A0 or A1, the loop seems to continue, but when I connect it to A2-A7, the loop seems to freeze until I disconnect it.

What am I doing wrong? I need to be able to detect when each of the analog pins have voltage applied to them. Is the Nano faulty? Or is the programmer (me) faulty?

My project needs to determine when each of the 8 pins have a voltage applied, independently.

Thanks for the help!
Mark

First, terminate all the Analog Channels/Pins (A0 - A7) to GND through 8x4.7 k pull-down resistors in order to prevent the pins from being into float states.

Now, carry out your experiments.

@fenbers
Everything that you described is absolutely normal behavior of the ADC pins if they are not connected anywhere

You are floating on a raft in the middle of the ocean.

The raft goes up and down with the waves.

You throw out an anchor so the chain is as tight as possible.

What happens ? :thinking:

Very interesting! I need clarification, though. Are you saying that I need to terminate all the UNUSED pins? Or that all of my analog pins need to have a 4.7k resistor regardless?
Mark

All the analog pins that you will be reading.


Also reading a pin, throwing that value away, then reading the same pin and using that reading is some times necessary.

Any delay in between?

I'll give this a try! I appreciate your wisdom and patience (i.e., your help)!
Mark

not exactly,

You terminate ‘outputs’, you bias, or pull-up/down an input to influence its quiescent state when not being driven by a source or sink.

Not needed.

You wake up?

This solved the problem. Thank you very much! I am now smarter than I was when I woke up this morning! :rofl:

1. After power up, all IO pins of NANO except A6, A7 come up as "input digital lines". A6 and A7 are always "input analog lines".

2. If the lines are not terminated by external pull-down resistors, then they are termed as "input floating lines" and may assume any logic level by picking up the environmental electrical "noise signal".

3. A0 to A5 lines become "input analog lines" when the the following code is executed:

unsigned int y = analogRead(A0);  //

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.