Arduino analogRead- Why there is always value even without input

I am trying to use the value of analogRead in a project. I did a small test like the bellow. Why there is always a value even without any input to the pin A3.

There is always a value between 300 -320.
I was expecting a zero. Am I missing something?

int analogPin = A3; 
int val = 0;                    // variable to store the value read

void setup() {
  Serial.begin(9600);           
}

void loop() {
  val = analogRead(analogPin);  // read the input pin
  Serial.println(val);          

  delay(1000);
}![output|690x452](upload://3wBdyQQwOVp3k231xi7uIR0ZiC6.jpeg) 

If you have nothing connected to an analogue pin to keep it at a known voltage then it can pick up electrical interference from the environment. Hence you get a value other than zero from analogRead() and that value may vary

1 Like

You wrote that the analogPin = A3 which means you define the pin on which you are going to place the object. And you want to bring that object value in serial monitor correct? I think you want to know the voltage. If you have nothing connected to an analogue pin to keep it at a known voltage then it will not show the right value and just shows picked up electrical interference from the environment. As it gets the value from enviroment for the same and any thing like 1,2,3 will show in the serial monitor. Hence you get a value other than zero from analogRead() and that value may vary.

So you should put something in the pin define. To get it voltage :slightly_smiling_face::blush:

Ground the pin with a resistor

no need if properly connected to an analog output device.

@UKHeliBob explained it in his post

You wrote that the analog Pin = A3 which means you define the pin on which you are going to place the object. And you want to bring that object value in serial monitor correct? I think you want to know the voltage. If you have nothing connected to an analogue pin to keep it at a known voltage then it will not show the right value and just shows picked up electrical interference from the environment. As it gets the value from environment for the same and any thing like 1,2,3 will show in the serilal monitor. You have to put some object in A3 pin for which you want to know the voltage.

again, should not be necessary. And depending on the output impedance, and resistance pulling the input one way or the other may affect the value

Yes I know but @dayDreamer1013 is not defined that he/she

So that's why a gernal response and a gernal issue

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