The problem that I am having now is passing the values of an array between two while loops. The problem is that a changing array is created in while loop 1 while while loop two is to write the sampled data when button is pressed.
This is sounding like an idea situation for the Producer/Consumer design pattern. You basically use a Queue to send the data between loops.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions Unofficial Forum Rules and Guidelines "Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5