What am i getting with unconnected pin ?

When i read with analogRead(0) with unconnected pin, what are these random numbers and how are they generated ?

Thanks for helping.

It is mains pickup, see:- http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

That pin is "FLOATING". What you are seeing is the influence or the misc. electromagnetic fields around the board at a instant in time. There is a mix of RF and 60Hz fields that are interacting and with the analog input pin connected those fields are enough to build up a charge on that pin. Digital inouts can show some of the same effect - being either LOW or HIGH but you won't see it as dynamically as you do on an analog input. If the reading on a pin is in any way important make sure the proper connections are made to properly condition the signal.

hmmm wonder if this behavior can serve (adequately scaled of course and with a speed penalty) as a "true" random number generator vs. the pseudorandom algorithm in the library ?

Its often suggested as a method of seeding the random number generator.

dxw00d: Its often suggested as a method of seeding the random number generator.

Makes sense... Thanks! One of the benefits of the pseudorandom generator algorithm is that it is supposed to generate a flat frequency distribution which is unlikely to be the case with analogRead on a floating pin and seeding it with this as you say would randomized it in a way timer counter may not.

One of these days nevertheless, i will try taking a look at what frequency distributions you can get on a floating pin :)