lets say the MCU uses millis()
.
unsigned long startcountthingy= 0;
unsigned long endcountthingy=0;
voided ThingyDetectorFunction()
{
if DetectorThingyOneGetStartSignal
{
startcountthingy=millis();
endcountthingy=0;
}
if DetectorThingyTwoGetEndSignal
{
endcountthingy=millis()
unsigned long HowLongThingyDetected = startcountthingy - endcountthingy;
}
}
or something like that