how analog input works? (from an electric point of view)

Hi! I'm experimenting with the Arduino and I'm on the "analog input" page :)

I just can't understand how actually the analog input works from an electrical point of view.

So, the default reference is 5v and that's read to 1024, but how it actually "feels" the voltage applied on the pin?

For example if you ground the PIN analog read report 0, because I assume all the current FROM the pin is drained to ground? But the pin itself is not "outputting" any voltage isn't it?

If you short the pin with the 5v pin you get 1024, how it "feels" those 5v?

Why then if you have GND-----|analog input |-----5v the sensor give 1024 even if it's connect to ground?

Why if I put a thermistor without a resistance the analog input fails to get the correct value and I need to put a 10K ohm resistor before ground it?

I know are probably stupid questions but I cannot find a precise answer on this...

Internally, the analog input pin connects to a capacitor. The A/D circuit then reads the voltage on the cap.
Connect the capacitor to ground, reads 0.
Connect the cap to +5 either directly, or with a pullup resistor, or a pullup thermsistor, it reads 1024.
Connect a thermistor from 5V to the cap, a resistore from the cap to ground, now you have a voltage divider, and the voltage will vary as the thermistor value varies.

http://en.wikipedia.org/wiki/Successive_Approximation_ADC

Oh neat, thanks for that link. Like an analog quicksort so to speak?

Thanks for the answers! That wiki page seems really exhaustive, I'll have also to dig into the "voltage divider" because I understand it's a fairly basic thing to master as it occurs and it's mentioned in several projects.

Thanks again guys! :)

Like an analog quicksort so to speak?

Binary chop

spirilis: Oh neat, thanks for that link. Like an analog quicksort so to speak?

No, its exactly binary search. Quicksort is probabalistic.