Hey I'm new to Arduino x c++ Language. Please respect this post, I'm only a young girl. I'm doing a project but this is a part I don't really know.
If the sensor detected an object, I wanted it to start a timer (5 mins) before the alarm triggers, but if the object suddenly left and the timer is not end yet I wanted it to go back from the start.
Some people said I need to use millis but I don not know how.
Some people said I need to use millis but I don not know how.
In the loop() function when the object becomes detected save the value of millis() as the start time and set a boolean to true. When the object becomes not detected set the boolean to false
Later in loop() test the boolean. If it is true and if the current value of millis() minus the start time is greater than 5 minutes then sound the alarm and set the boolean to false
My preferred method in dealing with timings is to use a library called Simple Timer. If you do not have it install it. Create a timer object then simply used a lambda timing function.