Pages: [1]   Go Down
Author Topic: What am i getting with unconnected pin ?  (Read 680 times)
0 Members and 1 Guest are viewing this topic.
Turkey
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thanks for helping.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33439
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1024
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
Nokia 6100 LCD Library
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Ardgrafix6100 - A fast, full-featured Arduino graphics driver for Nokia 6100 LCDs http://code.google.com/p/ardgrafix6100/

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
Nokia 6100 LCD Library
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
« Last Edit: April 26, 2012, 12:34:39 pm by srinathdevelopment » Logged

Ardgrafix6100 - A fast, full-featured Arduino graphics driver for Nokia 6100 LCDs http://code.google.com/p/ardgrafix6100/

Pages: [1]   Go Up
Jump to: