Random seed using analogread

Stuck? We'll be happy to help!
Post Reply
d.serafini
Posts: 3
Joined: Mon Jan 28, 2019 8:48 am

Random seed using analogread

Post by d.serafini » Mon Jan 28, 2019 9:22 am

Hi,
I'm trying to initiate the random generator using the analogread from one unconnected pin as I've read in many forum.
Unfortunately the analogread always returns 0, I've tryed from A0 to A9 and CONTROLLINO_A0 to CONTROLLINO_A9.

Do you have some ideas?
Is there any other good way to initiate the random generator?

Thanks.
Daniele.
(Board: Controllino Maxy pure)

User avatar
Mr. CONTROLLINO
Posts: 7
Joined: Thu Dec 13, 2018 3:07 pm

Re: Random seed using analogread

Post by Mr. CONTROLLINO » Mon Jan 28, 2019 3:42 pm

Hello Daniele,


All analog pins are tied to Ground from the voltage divider.
So you cannot create a random number with that method.


regards
Marco

d.serafini
Posts: 3
Joined: Mon Jan 28, 2019 8:48 am

Re: Random seed using analogread

Post by d.serafini » Mon Jan 28, 2019 4:22 pm

Thanks Marco, now the 0 get sense.
Do you know any other method I can use to initialize the seed?
(I've got no user interaction so I cannot use millis).

Daniele.

d.serafini
Posts: 3
Joined: Mon Jan 28, 2019 8:48 am

(SOLVED) Re: Random seed using analogread

Post by d.serafini » Tue Jan 29, 2019 9:06 am

Hi,
I've get good results using the <Entropy.h> library.

Thanks to all!

Post Reply