This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

The rand() function.

The rand() function in the stdlib.h is suppost to generate random numbers.
However in C programming the random number is generated from a variable eg time, date,..

Then in Keil, and the controller, how does this rand() function work..

Cause i tried using it, it worked ok..
The problem is everytime the controller is reseted, it generates the same set of random numbers. And if u randomize again, it will just become a patern instead of a random value..

Example:

after reset:

3,5,8,1,4,...etc etc..

after the reset button again...

3,5,8,1,4,...etc etc..


Does this mean there is no other way to generate random numbers?

Parents Reply Children