# Random Number Generator

I was wondering what parts I would need for a random number generator that basically does this:

Once a button is pushed it will show a number between 1 to 6 and it will remember this random number so it is not done twice(so as it is running a button will be pushed and it will get 4 , than it is pushed again and it will skip 4 and try out all of the other numbers from 1 to 6... It will also have an on and off button as well as a reset button to reset the random numbers to start all over again...

I am just wondering what parts I would need first to begin with , I have to order another arduino so would need recommendation on which one to purchase for this project (mini?)

In the future I will need help to make it work on a barebones circuit board

For now this thread will develop after I get the peices I need ..

Thanks much in advance for the help I will appreciate it much!

Here is how to get your numbers from 1-6 without repeating: http://c-faq.com/lib/shuffle.html

I'm sorry, but I can't help you, until we have signed a contract to share your lottery winnings, lol.

@KeithRB
the code behind the link can/will have an index out of range error

fixed version

``````	int a[10], i, nvalues = 10;

for(i = 0; i < nvalues; i++)
a[i] = i + 1;

for(i = 0; i < nvalues-1; i++) {
int c = randrange(nvalues-i);
int t = a[i]; a[i] = a[c]; a[c] = t;	/* swap */
}
``````

Here's some code I have found useful for generating a truly random seed value so your random sequence will be different every time your device is powered on. https://sites.google.com/site/astudyofentropy/project-definition/timer-jitter-entropy-sources/entropy-library/arduino-random-seed

Andrewm45: I was wondering what parts I would need for a random number generator that basically does this:

Once a button is pushed it will show a number between 1 to 6 and it will remember this random number so it is not done twice(so as it is running a button will be pushed and it will get 4 , than it is pushed again and it will skip 4 and try out all of the other numbers from 1 to 6... It will also have an on and off button as well as a reset button to reset the random numbers to start all over again...

I am just wondering what parts I would need first to begin with , I have to order another arduino so would need recommendation on which one to purchase for this project (mini?)

In the future I will need help to make it work on a barebones circuit board

For now this thread will develop after I get the peices I need ..

Thanks much in advance for the help I will appreciate it much!

First, I would suggest you keep it simple.

I would begin by forgetting about random numbers, and just making it count from 1 to 6, one number per button press. (This is to make sure that everything is working right: your button, the code to read the button, the code to display a number from 1 to 6, and the code to remember a number from 1 to 6.)

Once you can make it count from 1 to 6, then it would be a good time to work on random numbers. Random numbers are actually a surprisingly intricate topic, especially with a "no repeats" rule like you seem to want. I strongly suggest that you learn about "arrays", which are excellent tools for keeping track of a list of numbers.

if you want supposed actual random numbers, you can perhaps get a pebble or rock of a radioactive mineral, attach it to a Geiger counter, and sample.

you can use a radioactive source button of a single isotope as they do.

they say the distribution is Gaussian.

oh wow! so you can even take those gaussian distributions and makethem linear... heres part two of the random numbers video. :D

oh wow! so you can even take those gaussian distributions...

Ain't learnin' fun? Next step, the Poisson Distribution!

I think you are all over thinking this one, I assume he simply does not want two consecutive numbers the same. This, of course, stops it being a random number anyway. I would just do this:-

``````int lastNumber=random(1,6);
int dice(){
int thisThrow = random(1,6);
while(thisThrow == lastNumber){
thisThrow = random(1,6);
}
lastNumber = thisThrow;
return thisThrow;
}
``````

The Federal Information Processing Standard (FIPS) Publication 140-2 (FIPS PUB 140-2) compliant random numbers generator