Page 2 of 2

Re: Lottery Numbers Generator (Flowcode V4)

Posted: Tue Apr 16, 2013 6:55 pm
by tijs
the #include <rand.h> is taken care off
but the problem is when i try to run it it seems that my chip won't read the random
it always gives three times red an it shuold randomly change int re blue or green
can it be that my chip doesn't execute the random function??

Re: Lottery Numbers Generator (Flowcode V4)

Posted: Tue Apr 16, 2013 8:06 pm
by medelec35
Hopefully this should make it much more random.
I have seeded the random function with timer0 interrupt.
(Not tested)
Radom is not as random as you could believe it is.
when power to chip is first applied the random number sequences will be the same every time.

See:
http://www.matrixmultimedia.com/mmforum ... 45&#p42090

Martin

Re: Lottery Numbers Generator (Flowcode V4)

Posted: Tue Apr 16, 2013 8:30 pm
by JonnyW
Hello.

It helps to get something that feels more random if your program requires some human interaction. The chip may not behave randomly but people do.

Try waiting until the user pushes a button before starting, and before they do, spin in a loop seeding/calling the random number. This should get a more random outcome.

Jonny

Re: Lottery Numbers Generator (Flowcode V4)

Posted: Wed Apr 17, 2013 8:30 am
by tijs
thanks for the help when i tested it i wil tell you if it works