[Solved]Error in reading Analog values from two different ADC channels.

Hi,

I made a circuit to resolve another member' problem. But I am observing an anomaly in that.

Board : Arduino on Breadboard This is the Sketch:

int val1,val2;
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  val1 = analogRead(0);
  val2 = analogRead(1);
  delay(200);
  Serial.print("A0 = ");
  Serial.print(val1);
  Serial.print("\tA1 = ");
  Serial.println(val2);
  delay(1000);
}

I have used a voltage divider with two 10KOhm resistors across VCC and Gnd. A0 is connected to VCC and A1 is connected to the junctions of resistors(i.e. 2.5V).

I am getting

A0 = 1023 A1 = 824 (instead of 512 or near) the A1 value is slowly increasing.

I also checked the voltage at A1 Pin of the MCU and I am getting 2.5V in the multimeter.

Hey, I did not get that you did this for help me! thanks!

anyway I often get values around 800 (with 10-bit resolution) when the pin is floating!

It seems a common problem.So I gave it a try :)

Sorry the problem is resolved. @mbin you gav me the right hint, thanks.

I found the Problem.The MCU didn't sit right on the breadboard so it was floating.