Arduino MEGA analog problem

hey, guys
I'm a noob...
so my problem is that I designed the arduino as Voltmeter by using voltage divider.
Firstly, it was ok to measure the voltage... thereafter, i wanted to try it again,
and i discovered that the value was not accurate and 0 ( such as V= 11.xxV) when even i didn't plug anything on it....
its supposed to be 0 if i haven't plug everything on it... i m wondering if the arduino is kind of broken of fried out......
plz help me...

here is my code ....

int analogInput = 2;
float vout = 0.0;
float vin = 0.0;
float R1 = 50000.0;
float R2 = 4400.0;

int value = 0;

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

pinMode(analogInput, INPUT);

}

void loop(){
value = analogRead(analogInput);

vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));

Serial.print("Vin=");
Serial.print(vout);

delay(1000);
}

I think analog ports start with A, they're just a macro that boils down to a number, so try int analogInput = A2; (up top)

also your "Serial.print(vout);" you might want to change to "Serial.println(vout);" just so it prints a newline character to the serial monitor after the number, i.e. then each reading will show up on its own line.

caitlyn:
Firstly, it was ok to measure the voltage...

Okay...

caitlyn:
thereafter, i wanted to try it again,

So what changed?

Use another analog input. If it behaves the same, you probably have something in your circuit wrong.

spirilis:
I think analog ports start with A, they're just a macro that boils down to a number, so try int analogInput = A2; (up top)

Calling analogRead() with A2 or 2 results in the same pin being used.

caitlyn:
the value was not accurate and 0 ( such as V= 11.xxV) when even i didn't plug anything on it....
its supposed to be 0 if i haven't plug everything on it...

No it isn't. With nothing plugged in it reads random noise.