How would you save an unlimited amount of values from button presses?

Hello everyone! I have recently started on my first project. I made a tank that is controlled by button presses but values are inputted beforehand, and movement starts with the press of a “Go” button. My tank works, up to 24 button presses, but I realize that my code is horribly inefficient. May someone please inform me of a better way of doing this? Either another example project or a written explanation is fine. Thank you very much! Also does anyone know how to make motor turns more consistent? An issue I have is that on high battery the tank over turns, on low battery the tank under turns, and after continuous turns I think that it is under turning a bit. Any ideas?

Video of tank to understand how it works: Arduino Button controlled tank test - YouTube

The code is as an attachment as it is too long to post in text.

ButtonTankGoodADDINGhelp.ino (37.9 KB)

... and that's why they created arrays.

Yes I know I could of done that. My concern now is how I can make an array that is as big as the amount of button presses entered. So if I only went 3 steps it would go 3 steps but if I went 50 steps it would go 50 steps. I apologize for the horrible code but I couldn't really find any user projects that use the same sort of button saving system as mine. Most other projects I found were live response feedback from the button presses.

Yes, you could have done it. So why didn't you?

You've got twenty-four variables. Do you think they use more or less RAM then a twenty-four element array?

Becuase I'm a noob? I wanted to create something that worked at first that I could refine later. My question now is whether or not I can many the array size based on the number of button presses I have.

What is the absolute maximum number of presses you expect?

(we were all noobs here, once. Post count != experience)

Well I was taking it as a sort of challenge to see if I can make something in which button presses defined the length of the array, but I guess you’re right. I should just make a maximum with arrays and leave it as that. Thanks for your help.

I just took a look at your code: It looks like cases sc2 (line 904) to sc23 (ends line 1298) are all identical.

Yup :/

So when you have lines of code that are identical then it is god’s way of telling you that you need to use loops and arrays.

The small memory of an embedded processor like the Arduino is both a problem and a solution. Here it's a problem because you can't have 'unlimited' storage. You must find out what size of array will fill 100% of the Arduino's memory.

The reason why it's a solution is because you aren't going to do anything else with the Arduino. You aren't going to want to watch youTube videos on it while it runs, so you know that using 100% of the memory is just a good efficient way to use memory.

Note: Don't fill it up until the compiler says 100%. You still need some space for 'local' variables.

Grumpy_Mike: So when you have lines of code that are identical then it is god's way of telling you that you need to use loops and arrays.

....that, and variable names identical, apart from the numeric suffix.