1

After watching something weird on the serial monitor I wrote a simple code to monitor the analog pin input values. There was nothing connected to the analog pins still they where showing decimal representation of some analog values.

the code is

float ana [] = {A0,A1,A2,A3,A4,A5};
float dec [6];  

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

void loop() 
{ 
  for(int i = 0; i<6 ; i++)
  {
    dec[i] = analogRead(ana[i]);
    Serial.println(dec[i]);
    delay(1000);
  }
}

How is this even possible?

this is the output result

enter image description here

3

Your input is floating if nothing is connected. It is reading whatever random noise it happens to pick up. That's what it is supposed to do. For it to read 0 it would need to be connected to ground. Google "floating input" for more info.

| improve this answer | |

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