Arduino Lotto number generator

While teaching a friend of mine about the arduino set I recommended to him, he had an idea for a little project he wants to try next. I thought the thought was interesting, so I gave it a try myself so I can help him more easily.

The task: Have the arduino generate random numbers to use for the “LOTTO 6 aus 49” lottery. The numbers to generate are simple: you need 6 numbers from 1 to 49 and one “Superzahl” from 1 to 9 at the end. The Numbers should be displayed on the LCD display so you can easily run it on battery and make it portable.

My solution: To my current knowledge none of the available random functions are truly random. Especially on the Arduino they’re Pseudo-Random and not quite the solution we’re looking for. Even though it would be random enough in theory, I wanted to try and find a more unpredictable way. My idea to do that was to introduce the human factor. Making it similar to a slot machine, I used a button that the user would have to press for each number while the Arduino loops through all the possibilities one by one on each tick. Once the button is pressed it locks the number in and starts the loop for the next one.

I think this way is the closest to “truly random” as you can get easily with just these components.

I will include a download link to the source code below, but it still has one obvious flaw: it doesn’t check for duplicates – which is not possible to use for the actual lottery. I decided that I were done with this contraption, since my friend had the duplication check figured out fairly quick on his own.

Click here to download the arduino source code: Arduino Lotto Generator project files

Bookmark the permalink.

Comments are closed.