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?

asked Jan 25, 2016 at 22:23
1
  • 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. Commented Jan 26, 2016 at 3:27

2 Answers 2

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.

answered Jan 25, 2016 at 22:28
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.

answered Jan 25, 2016 at 22:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.