What happens when you read two anolog pins at once?

I read that Arduino can't read multiple analog inputs at once because there's only one ADC and you have to give it some time to "cool off" before reading another analog input.

simultaneously reading two analog inputs with arduino

However, I'm not seeing any issue reading two analog pins in the same loop. The following code seems to work fine. The serial monitor is behaving normally. What should I be noticing that isn't working?

I have a potentiometer hooked up to A0 and one on A5. All the unused analog pins are grounded through a 1k resistor.

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);
}

// the loop routine runs over and over again forever:
void loop() {
    int sensorValue0 = analogRead(A0);
    int sensorValue5 = analogRead(A5);


    Serial.print(sensorValue0);
    Serial.print(" ");
    Serial.println(sensorValue5);
    delay(100);        // delay in between reads for stability
}

You cannot read two analog pins at once because there is only one A/D in the Arduino. There is a multiplexer (aka switches) that connect each Analog pin to the A/D one at a time.

BTW what you are doing is fine. Should be no problem EXCEPT...

In certain cases like in your case A0 is very high (4.5volts) and A5 is very low (0.05V) reading them very quickly in succession could cause the A5 reading to be a little high because the A/D sampling input has not had time to settle at 0.05V from being at 4.5V.

If you looked at the processor data sheet you will find a block diagram that shows the above. Even if you are not experienced at reading specifications you should be able to understand how the blocks interact.

1 Like

Source impedence plays a key role. See Input Impedance of A0-A5

2 Likes

By Arduino I assume you mean an AVR-based Arduino like the Uno?

Yes there is one ADC, and an analog multiplexer on its input to select which pin is connected to it.

The "cool" off thing is probably due to the requirement for low source impedance. If you connect signals with a source impedance of 10k or less to each analog pin you can read them however you like in any sequence with no issue, all is fine.

If some/all of the inputs have significantly higher impedance you will need to do double reads after changing pin numbers, to allow the sample/hold capacitor to fully charge in the very short time between the analog multiplexer switching and the analog conversion starting.

Your source impedances are no doubt low then.

1 Like

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