You need to consider how you are going to read back the data and what it needs to look like in order for your "replay" function to parse/understand it.
This will be my next problem after storing the data.
If you write sensor and switch data in sequentially different spots in eeprom this might confuse as to what type of data it is.
I write "sensor data" first in odd address then the corresponding "switch data" on the next address (even). Data always come in pair and they are stored alternately.
Also consider how fast this data can be written because this will affect your length and "resolution" of playback. You will likely get a much finer resolution then you desire.
How do I do this?
So you will have to make rule about when to sample the data, which you are kinda doing with the switch.
Sensor Data is sampled while "footsw" is at logic high. It stops when "footsw" becomes low. Sensor data is stored in lastsensorVal. The sensor data for the previous step will be added to the next sensor data. The value will continue to add until "leftsw" or "rightsw" is pressed.
You're absolutely right. The totalsensorVal will continue to rise assuming that each step is over 400.
Third and most importantly, this sounds like a run time operation, unless the user needs recount their steps after they have turned off and on the device, you don't need eeprom. In which case its back to storing this in an array. This is better considering your sensor value will be over 400. 400 wont fit in the byte you address in eeprom it can only store up to 255.
Can you help me transform my code so it will be stored on an array instead of the EEPROM? I could not find a good link for me to learn storing data in arrays. It would be better if I learn it too. The arduino examples for array don't help. EEPROM read, write, clear are easier to understand.
I suggest estimating the greatest length of playback(in recording steps) this will help whether you need persistence(eeprom) or not. This way you can pre-define the size of the data structure and be sure the recording fits where you want to put it.
But wait! I think I can do this.
sensorVal = analogRead(A0) / 1000
The value 400/1000 would just be 0.4
But I will have to change my "int" to "float".
Is this a possible solution?