How to generate a random sequence, and store it somewhere

Hi everyone!
(Testing with the #4 Arduino Nano - Which yet still alive and working - 7 Total)

I'm trying to write code which generates an alphanumeric sequence that has an 'x' number of digits (I will need to change the value of x after ).

  • I need to store the code that was generated somewhere (EEPROM, maybe), im afraid i'll be using the #5 one soon... :s

May someone help me? Thank you for you time and patience :slight_smile:

What is #4 Arduino nano? And why are you afraid that your using #5 soon?

Generate a random number (see random())
Store in array (see array reference)
Repeat till you have enough numbers (use e.g. for)
Write array to eeprom (see eeprom reference; probably using put and get)

Try something (or show us what you tried) and we can help you further.

Initialise random() with a specific number, using the randomSeed() function. For example

  randomSeed(1);

Then using the random() function after that will give you the same sequence every time.

If you've ever played the Freecell game, the "numbered games" are actually the numbers for the random seed.