??? 03/05/10 10:48 Read: times |
#173870 - random permutations Responding to: ???'s previous message |
One way to greate the random number is to do a virtual shuffle by letting each random value select which of the unlit diodes to turn on.
First time, the LED area is empty, i.e. 9 slots to select between. Generate a random number between 0 and 8 to select the first LED to light. Generate a random number between 0 and 7 to select which of the still unlit LEDs to light. Generate a random number between 0 and 6 to select which of the still unlit LEDs to light. ... If having ROM space over, you can generate n permutations of the numbers 0 to 8 and store in the flash. Then you only need one random number to select which permutation to use. If displaying a 5, you pick up the first 5 numbers from the permulation, and light the corresponding LED. A permutation of 9 numbers can be stored as 9 nibbles in 5 bytes, allowing 512 byte of flash to store 102 different permutations. That should be enough to make it very hard to see any repeating pattern, as long as the (pseudo)random generator used to greate the permutations and to select the current permutation is good enough. |
Topic | Author | Date |
"binary" clock | 01/01/70 00:00 | |
You mean one of these? (should be a doddle) | 01/01/70 00:00 | |
No... not this one | 01/01/70 00:00 | |
Oh, I see - that's not "binary" at all! | 01/01/70 00:00 | |
Yes! Thats it! | 01/01/70 00:00 | |
World's most unreadable clock? | 01/01/70 00:00 | |
random permutations | 01/01/70 00:00 |