Instructables

Random number generator

I am looking to purchase or looking to make or looking for someone to make or show me how to make a simplistic ramdom number generator with a simple 2 digit lcd readout. This will be used as an automatic dice roller for a board game. The random numbers can be fixed to read out from 1 - 12 or even up to 24. Or, if not too difficult, programble, to make it more versatile Perhaps a prototype could be made by using some existing components such as from a digital clock or watch. Can anyone tell me if; 1. There is anything like this on the market? 2. There is an easy, inexpensive way to built something like this? Or 3. If someone would be interested in building something like this for me?

LasVegas7 years ago
There is no such thing as a true digital random number generator. This is why they're called pseudo-random. You could get a random number by incrementing the number looping from 1 to 12 as quickly as the circuit would allow and display the current count when the user presses the button. In this situation, the random action is the time it takes the user to press the button.
do you know how to play the roullete bergmann slot machine...?
LasVegas is correct. Check out this site: http://www.random.org/
VIRON LasVegas7 years ago
I agree, just going to say the same thing, the only true random number generator must count very fast and be stopped by the "observer". No uC is needed... (a couple of TTL's and LED display is cheap+simple) Digital watch... hmmm... if you can overclock one (much faster crystal), and just use the set-hour mode ... there you go! Just like the picture.
dietbrisk5 years ago
i thought about this once. the solution i came up with: have a unit that counts from 0 to N-1, based on the board clock, and once the input is pressed, display that number + 1 and hold it on a register. it's not a real number generator, but the clock is going so fast (25 MHz on my board, anyway) that the probably of the system acting random is very high: trying to 'time' 25MHz/N in your favor is improbably small. and, for the needs of an extremely small program like a dice, it's suitable.
jman115 years ago
The easiest way i know is to make a variable and a loop that changes the value of the variable.... not totally random but its about the most random thing you can get. If you are coding in C or C++ tell me and i would be glad to share some of my code. :)
kelseymh5 years ago
Did you ever try "electronic dice" in Google? Lots of hits, both for projects you can build and products you can buy.
There is a solution using a programmable calculator. There are many programmables, but if you want to give it a try with a Hewlett Packard HP-33s, here's an example of how little effort it would take. As a bonus, you would have the option of any range of numbers. For a 1-12 dice scenario, the program would look like this in native calculator code: [grn, PRGM] (Goes into program mode) LBL A 12 RAND * IP 1 + RTN [grn, PRGM] (Exits program mode) To run, press R/S once for each roll of the dice. In the program change 12 to 24 to have a range from 1-24, or change the 12 to 6 to make it like a regular single die. Then press R/S twice for two six-sided dice, or four times for four dice. Just my nuisance two cents. :)
What kind of dice are you trying to simulate?
good point. A normal pair of dice won't roll a "1", and tends to roll lots of "7"s. A random 1-12 picker is like a DnD dodecahedron, or a clock face spinner.
westfw7 years ago
From a logistics point of view, you're going to have trouble finding a 2-digit LCD display like that at a reasonable price. LCD "glass" tends to come in a few standard formats (clock display), and "custom designed." It would be a lot easier to do in LEDs, and THAT'S been done many a time (though I don't know offhand whether there's one with a XdY (X dice with Y sides each, ala DnD) programmable capability. It shouldn't be hard. Electronic Dice Kit might be a good starting place.

(or, you might be able to use a cellphone display, if you can find one that's well documented.)
CSUjr (author)  westfw7 years ago
Thank you westfw, I've ordered one and will try it out. Regarding the price; Well this comes from the UK (I'm in WA State, USA) so after the shipping and converting Sterling Pounds into USD it's running $35+.
westfw CSUjr7 years ago
Sorry about the price; a lot of these kits are manufactured off in China/etc and sold by many vendors, so I didn't bother looking specifically for a US source. Although now that I have, I can't find one anyway... Note that the 18pin PICs all have compatible pinouts, so you should be able to drop in a more-hobbyist friendly chip instead of the one that comes with the kit, if it has a socket...
CSUjr (author)  westfw7 years ago
Thanks westfw, Yes, I plan to examine the components and see if I can purchase what I need, locally, to build a couple of these. I think that most of the components will be common and readily available but can you give me some idea about what I will need to look for as far as a "processor" (the component that generates the numbers)? Thanks, Charles P.S. sorry for the double posting. I'm new here and did not know if these were different forums or not.
westfw CSUjr7 years ago
Well, you can look at the How to Choose a Microcontroller instructable. For two 7-segment displays, you probably want to have 9 output pins, and a couple inputs to select max value or whatever. Unfortunately, that'll eliminate some of the lower cost "easy" solutions like the basic stamp 1 or PICAXE (which only have 8 outputs, as far as I can tell.) But you should be well within the capabilities of 14 to 18pin PICs or AVRs. (or, come to think of it, you could probably implement this on the $20 Atmel Butterfly Evaluation Board
0 to 15, four bit, maybe a linear feedback shift register (a few xor and shift register from 74 logic series), with 7-segment display instead of LCD?

http://en.wikipedia.org/wiki/Linear_feedback_shift_register
CSUjr (author) 7 years ago
Thanks for your reply. As long as it will generate different numbers, it sounds like it will be okay for what I want. Do you have any suggestions on either, where I can get one, get one made, or make one myself? Charles
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!