random number generation with at89c51 using C

Status
Not open for further replies.

nyxon

Newbie level 2
Joined
May 25, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
i m tryin to create a dice for which random no. generation is necessary.
i had used rand() function under stdlib.h but it keeps on givin the same no.
what are other method of generation random no. using C language

my code was like this

int r;
r=rand()%7;

this should generate random no. between 0 to 6 but instead it generated only 2 every time it is executed.

plz help!!
 

check this
**broken link removed**

---------- Post added at 08:21 ---------- Previous post was at 08:18 ----------

this has everything you want.. just register yourself in this site to access everything
**broken link removed**
 

nyxon

You must provide the seed before call that function.
That´s because RAND performs a pseudo-randomizing algorithm.
Generally we use an assyncron event to trigger an internal uC counter and feed the function.

+++
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…