1

I used the example code AnalogReadSerial and tried it on all analog pins from A0 to A7. None of the analog pins were connected to anything so I expectedy to get 0 in the serial monitor. But as it turns out, I was wrong. Only pin A7 shows 0 to 19 values on the serial monitor. The rest have values ranging from 100 to 300 for pins A2, A3, A4, A5 and A6. The worst performers are A1 and A0 with values from 921 to 1023 showing on the serial monitor. What is the cause of this and how will I fix it?

  • None of the analog pins were connected to anything so I expected to get 0 - what you should actually expect is an undefined value. how will I fix it? - don't try to read "floating" or unconnected pins. The action has no meaning. – Nick Gammon Jan 26 '16 at 3:27
1

The ADC is multiplexed across the pins, and will carry a small charge from pin to pin. If you want them to be zero, tie them to ground.

This answer, https://arduino.stackexchange.com/a/575/6628 , suggests pulling them to ground for higher accuracy.

3

This is normal, as the unconnected pin may float from GND to VCC. You may enable internal pull-up (to VCC). This is normal for all high-z inputs. If you read digital port you'll see that it floats too. Sometimes you can change digital I/O input value just by waving your hand above the board.

For that reason we always tie high-z inputs to something. You can leave it floating - it won't damage anything, but the value obtained from free-floating input is useless.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.