chipKIT® Development Platform

Inspired by Arduino™

what is the best way to seed randomSeed

Created Sat, 10 Mar 2012 21:31:30 +0000 by toomuchcoffeecoder


toomuchcoffeecoder

Sat, 10 Mar 2012 21:31:30 +0000

I have tried using analogRead but the readings are to stable, even if I am doing a reading for each bit of the seed. This is the technique reccomended for atmel based arduinos but it isn't working on the chipkit board there is just not that much float on the inputs.


toomuchcoffeecoder

Sun, 11 Mar 2012 01:02:34 +0000

Well I found a fix that works for me I am seeding randomSeed using the micros function.

randomSeed(micros());

especially after waiting for some input this value is unpredictable and does the job for what I am doing.


toomuchcoffeecoder

Sun, 11 Mar 2012 09:14:17 +0000

I have also switched from the randomSeed and random functions to ISO C rand and srand seeded with micros(). This seem to be giving me a more random looking distribution of numbers but I could just be tripping they are supposed to be random numders after all.