Retrigger and hold bool value for certain time

Hello guys

I need to re trigger a bool and hold it for some seconds before it comes down to 0 again .

lets say i have a button when i pressed becomes 1 if i release the button it should remain the 1 for 3 seconds if i press one before the 3 seconds it will retrigger so remain 3 seconds before 0 again. something like a monoflop.

Some years ago i think to remember there was a library that was doing that , maybe i,m wrong and it was the opposite with bounce.

anyone remember that library name or a quick way of doing this ?

thanks

hi , in the end i did it using the stopwatch library like this :

#include <StopWatch.h> 

 bool Test = false;
 int SensorValueThr=400;
 int TimeToDie=5000;
 int SharpSensor = 0 ;


if(SharpSensor > SensorValueThr)
{
ContadorActivo.reset();
   
  

Test = 0; 
 

}

else if(SharpSensor < SensorValueThr)
{

 ContadorActivo.start();

}
 
if ((ContadorActivo.elapsed() > TimeToDie)&& SharpSensor < SensorValueThr){


Test = 1;

}

cheers

You could do it using millis() as illustrated in several things at a time.

...R