Storing sensor data in an array

Apologies this is a simplified version of the code I made to post here (i.e I deleted a lot of the manipulation of the data that happens after the array as this is not relevant) I have changed the code now.