Two of my Arduino Uno v3 analog inputs acting wird

When I read my analog inputs without connecting anything to them I should get aleatory values, right? But in my case, A2 and A3 inputs return 0!

If I connect a very strong input signal to them (eg. from 3.3v or 5v straight to A2 or A3) I get a correct read, but they ar easily influencing each other, for example: if I put 3.3v to A3 i get A3-> 720 and A2->600. The rest of neighbor inputs are fine!

Sorry for my english!

untitled.JPG

The analog pins are multiplexed to a single A-D converter. Because doing the conversion involves charging a capacitor, reading different pins one right after another can give misleading values. One partial workaround is to discard the first reading of a pin. Better yet, discard the first reading, then read the pin several times and average those values do dilute any carryover. (BTW, as you didn't post your code, but just the output, it's rather hard to know exactly what you did.) Ciao, Lenny

This is the code:

int s6 = A5;
int s5 = A4;
int s4 = A3;
int s3 = A2;
int s2 = A1;
int s1 = A0;

int s6_v;
int s5_v;
int s4_v;
int s3_v;
int s2_v;
int s1_v;

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

void loop() {


  s2_v = analogRead(s2);
  s1_v = analogRead(s1);
  s3_v = analogRead(s3);
  s5_v = analogRead(s5);
  s4_v = analogRead(s4);  
  s6_v = analogRead(s6);

  
  Serial.print("s1 ");  
  Serial.print(s1_v);
  Serial.print("\t"); 
  Serial.print("\t"); 
  
  Serial.print("s2 ");  
  Serial.print(s2_v);
  Serial.print("\t"); 
  Serial.print("\t"); 
  
  Serial.print("s3 ");  
  Serial.print(s3_v);
  Serial.print("\t"); 
  Serial.print("\t");

  Serial.print("s4 ");  
  Serial.print(s4_v);
  Serial.print("\t"); 
  Serial.print("\t");  

  Serial.print("s5 ");  
  Serial.print(s5_v);
  Serial.print("\t"); 
  Serial.print("\t");  
  
  Serial.print("s6 ");  
  Serial.print(s6_v);
  Serial.print("\t"); 
  Serial.print("\t");  

  
  Serial.println("");  
  delay(100);               
}

Even if I read a single pin (A2 or A3) result is the same! :(

If you read about FOR and WHILE it might make life easier ...

What do you mean by "Even if I read a single pin (A2 or A3) result is the same!" ? Your code reads all the pins one after the other without any of the discards that were recommended by @lrobbins.

You should read the Atmega 328 datasheet to get all of the details about using the ADC converter.

...R

Doing this might be all you need, as suggested already:

  s2_v = analogRead(s2);
  s2_v = analogRead(s2);

  s1_v = analogRead(s1);
  s1_v = analogRead(s1);

  s3_v = analogRead(s3);
  s3_v = analogRead(s3);

  s5_v = analogRead(s5);
  s5_v = analogRead(s5);

  s4_v = analogRead(s4);  
  s4_v = analogRead(s4);  

  s6_v = analogRead(s6);
  s6_v = analogRead(s6);

or possibly add delayMicroseconds(100); in between pin reads.

It is odd that 2 pins are not floating at all when disconnected, I would agree with you there.

Is your hand or any metal-pieces ever touching the card? You're not holding it in a sweaty palm, are you?