ofGetElapsedTimef() issue?

Hi All,

I’m writing a program which has an area requiring a timed delay before an event happens. I searched around the forum but didn’t quite find anything that solved this problem, hopefully it’s a simple one that is only plagued by my sleepless nights.

Here is a snippet of the code:

  
    if (gridaa < 5)  
        if (gridab < 5)  
            if (gridac < 5)  
                if (gridad < 5)  
                    if (gridba < 5)  
                        if (gridbb < 5)  
                            if (gridbc < 5){  
        ard.sendDigital(9, ARD_LOW);  
	    ard.sendDigital(11, ARD_LOW);  
	    ard.sendDigital(13, ARD_LOW);  
	    timer = ofGetElapsedTimef();}  
	    else  
            if ((ofGetElapsedTimef() - timer) > 10){  
                ard.sendDigital(8, ARD_HIGH);}  

And so as these nested IF statements all check out, it sends the low signals to the arduino for pins 9, 11, and 13. This all works great. The problem I’m running into is trying to create a delay for after all of those IF statements check out, to run a high signal to pin 8 on the board.

This iteration works to an extent, the problem is that the program is continually storing ofGetElapsedTimef() in my timer if gridaa-gridbc stays below 5. I can sit there an watch it count up like a stopwatch. What I need is a way to store it once and reference, and almost freeze it until gridaa-gridbc allow it to reactivate.

Am I overcomplicating this?

Lastly it might help to know the goal of the code: I’m using incoming live video source to trigger hitboxes which in turn trigger Arduino pins, but I’d also like a delayed event to happen if no hitboxes are triggered (no motion) for a certain period of time.