So basically i have 3 buttons and i want to hit them an arbitrary amount of times (no more than 20-30) and then read back what i've pressed. Each button will represent a block of code. After pressing a fourth button, i want it to start running through the sequence of the pressed buttons.
For instance if i press ^ ^ ^ > ^ < ^ it will then sequentially execute the code for what those buttons represent.
Ive tried using an array but i really dont understand arrays. I was then going to use the EEPROM.write, and EEPROM.read but i may exceed the approximate 100,000 read/write life of the onboard eeprom by the time its all said and done.
Does anyone have any advice on how to do this? Hopefully i was clear enough on my description.
Declare a byte array big enough to hold the total number of button presses expected and an index variable to point at the next array entry to be used.
byte buttonPresses[40];
byte arrayIndex = 0;
Each time a button is pressed save the button number to the next array entry and increment the index variable and put a marker in the array to indicate where the end of the sequence is.
There is still work for you to do to check the stored numbers as they are read from the array and to do whatever you want depending on the number but I suggest that you start by simply printing the numbers as above.
Agreed. The end of sequence marker is not necessary, but I quite like the idea as it is a very understandable technique, and the OP will encounter C style strings where a similar marker is absolutely necessary