I am trying to run the following code. But I couldn't get the expected result. It is for an Arduino-based system. I need to run some Tests. Each test has two parameters. The number of 'Samples' and how long each sample to be tested. For example, if the s_count = 5 and t_count = 10, there are a total of 5 samples and each sample should be tested for 10 minutes. During this 10 minutes sample, I want to generate the result every minute and at the end, I calculate the average (of 10 minutes result). Following is my code. I ended up in an infinite loop inside the second while loop. Any suggestions, please.

```
unsigned long previousMillis = 0;
const long interval = 60000;
void startTest(int s_count, int t_count)
{
int sample_number = s_count;
int test_time = t_count;
while(sample_number > 0)
{
while(test_time >0)
{
unsigned long currentMillis = millis();
// do measurement every one minute
if (currentMillis - previousMillis >= interval)
{
previousMillis = currentMillis;
doTest();
test_time--;
}
}
// reset the time counter after finishing one sample
test_time = t_count;
// go to the next sample
sample_number--;
}
}
```