Lottery Numbers Generator (Flowcode V4)

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

tijs
Posts: 7
Joined: Tue Mar 12, 2013 4:57 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Lottery Numbers Generator (Flowcode V4)

Post 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??

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Lottery Numbers Generator (Flowcode V4)

Post 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
Attachments
keuze ledjes3.fcf
(26.61 KiB) Downloaded 428 times
Martin

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Lottery Numbers Generator (Flowcode V4)

Post 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

tijs
Posts: 7
Joined: Tue Mar 12, 2013 4:57 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Lottery Numbers Generator (Flowcode V4)

Post by tijs »

thanks for the help when i tested it i wil tell you if it works

Post Reply