EEPROM programming

I would like to create a Simon game between two Arduino users connected via serial that allows one user to store a user generated sequence of up to 10 numbers rather than randomly generated sequences. This means capturing the button input, recording it to the EEPROM, and then sending it to another Arduino via serial.

One way to approach this would be to store the data on the local Arduino, then send it to the other Arduino. Another idea is to just send each button press to the other Arduino via serial and have the other Arduino store the numbers until the sequence is done. In both cases the other Arduino user would then try to match the recorded sequence.

It would seem to me best to have the sequence recorded on the sequence originating Arduino and then send the whole sequence to the other Arduino. In addition to getting some guidance on this method of data transfer I was wondering if someone could give an example of how to record and write to the EEPROM for the purpose I mention above.



Is there some reason for committing the user-generated sequence to long-term storage? The idea behind using EEPROM is to persist data even when the power is shut off. I can’t see any reason to do this with user-defined button press order information.

You could define an array of some fixed size. Make it large enough to be interesting, but not so large as to be ridiculous. Record each button press at the next position in the array, and then send the array when the sequence is recorded. If there are less than 10 buttons, each button number is a one digit number which makes it easy to send as either a character or a byte.

No, there isn't any reason to committing the sequence to long term memory. I thought that was the only option for holding data before it gets read.

And yes, I am planning to send the digits as bytes. Is it possible to create a 10 button array, but if the user chooses only to fill 6 to then terminate the array earlier, such as by using a series specific buttons to signal the end of transmission?

You would definitely need some way to indicate the end of a sequence. By 10 buttons or less, I was referring to the number of discrete buttons that could be pressed, not the number of button presses that make up a game.

The traditional Simon game uses 4 buttons/color, but that could be expanded to 6 or 8 or more. If you extend it to 10 or more, then the button number can no longer be represented as a single digit, making the sending a bit more complex.

The number of button presses that make up a sequence need not be limited to 10 values.

Got it. I will keep it to 4 discrete buttons for now. I was just focusing on the number of button presses.