As a followup of the discussion in this thread
, I decided to look at the frequency distribution of values you get by using analogRead() on a floating (unconnected) analog pin.Background
A "good" random number generator should have a "flat" frequency distribution (equal probability of getting any number in range) - which of course is unlikely in this approach. The better approach is to "seed" the default pseudorandom generator in Arduino library - which does approximate to flat distribution - with some kind of random value - either a timer counter or as discussed in the post, analogRead() on a floating pin. The seed should be a fairly random, wide ranging number.Test
I generated 1 million values from analogRead() on a floating pin, sent each value to my computer using serial & built a frequency distribution in excel.Results
99.5% of the 1 million values were distributed between just 38 values
out of 1024 possible values. Hmmm.... does not seem to be a wide "seed" range by any means
Comments / Thoughts welcome.