store sensor values into an array

meowth08:
Thanks for the replies.
My apology for not posting the requirements clear.

The pseudo code posted by UK HB was I think the same as what I am trying to do.
But one thing is missing. I also want to record what switch was pressed.
From my first post, I assumed sw1 as 0 and sw2 as 1.
So my array would look like [ 500, 0, 600, 1, 300, 1 .....and so on and so forth]
The first element (500) is my sensor value.
The second element (0) denotes that sw1 is pressed.
The third element (600) is also a sensor value.
The fourth element (1) denotes that it is sw2 which is pressed.
I hope I'm being able to explain the requirements clearly now.

For UKHB's reply/questions: I am having problems storing the data as an array.

How many entries are there likely to be ?

The size is not definite but I think it would not exceed 30. Is it ok?

Will the run ever start over again with previous data in the array ?

I don't understand this question sir.

Putting the data into an array implies that you are going to read it, which you can do in a similar way.

I will read it.

You will lose the data in the array if power goes off. Is that OK ?

OOPS! not OK. I have plan B. How about the EEPROM? Can I use it instead of storing my data in an array?

My pseudo code stored a value for the switch pressed. 0 for switch 1 and 1 for switch 2. The array holds data for 'number of switch pressed' and 'data read' in alternate bytes. I actually had them the in the opposite order than you asked but that is easy to correct.

"Will the run ever start over again with previous data in the array ?" What I had in mind was that after a run the array will have data in it. If you run the data collection again without clearing the array it will already have data in it. How will you distinguish old data from new when reading it back if there are fewer entries in the second run ? An entry in the array to signify 'end of data' would be advisable. 30 entries, actually 60 because of collecting the switch numbers, will not be a problem unless the data is a huge string of text, which I take it is not the case.

Have you got any code written, even if is not working ? Please post it so that we can help.