Time counter project

Greetings. I am completely new to a forum and very new to Arduino programming. I am working on a project with my daughter and am looking for a direction to go. Basically the project will use a sound sensor and when the value is above a certain analog value over a certain period of time it will add that time to a counter. if the total time is 10 minutes then it will activate a digital output. I just don't know where to start with the time function and referencing the analog sensor since it will fluctuate quite a bit. Simply we will be monitoring a cello playing and trying to monitor it as it will produce a higher amount of analog values over a time line as compared to normal ambient sounds. we are trying to then run a timer when those values average high over that set monitor period (such as 30 seconds) and then all of that time adds together to accumulate a 10 minute play time.
Appreciate any help in what functions to use for the time and count functions.

Hello
The BlinkWithOutDelay example to be found in the IDE is the mother of all time handler used wihin the Arduino biotop.
Have a nice day and enjoy coding in C++.

1. You start with the following two empty functions of the IDE.

void setup()
{

}

void loop()
{

}

2.
(1) Connect the sensor at: A0-pin of UNO (for example).
(2) Set the target level of the ananlog value at: a1 (for example)
(3) Set the target time at: 200 ms (for example).
(4) Decare the counter as: unsigned long timeCounter = 0 (for example)
(5) Declare the target output port as: pinMode(8, OUTPUT);

3. Write codes for the text codes of Step-2.

pinMode(8, OUTPUT);
unsigned long timeCounter = 0;
unsigned long presentMillis = millis();
while (millis() - presentMillis <= 200)
{
     unsigned int x = analogRead(A0);
     if(x < a1)
     {
         break;
     }
}
timeCounter = timeCounter + 200; //edit
if(timeCounter == 10*60*1000UL)   //10 minute time = 600000 ms
{
     digitalWrite(8, HIGH);
}

4. Insert the codes of Step-3 at the appropritae places of the empty functions of Step-1, compile/upload the sketch, and observe the result.

GolamMostafa,
I think you had a bit of finger trouble and meant:

timeCounter = timeCounter + 200;
1 Like

Or:

timeCounter += 200;`