Servo motor and break beam

Sorry if this was already asked, I was not able to find anything similar to my project.
So I have a system that has a break beam sensor that detect the motion of a prosthetic hand that is being operated by a servo. We are testing for failure with making the hand grip back and forth (so the sensor will show broken-unbroken-broken,etc throughout the experiment)
What I am looking for is that when the sensor detects broken for a certain amount of time (say 5 minutes) means that the hand failed and the servo should stop. I was wondering if this is possible and how would I do the code (I have the code for the break beam and the servo separately).

Also sorry if this is not the right forum, I am a bit new to this.


I assume that the hand is tested and working as well as the breake beam part. If You have manage do create that code You should be able to code that time supervizing part. What is the problem?

When the failure is detected save the value of millis() then each time through loop() compare the current value of millis() with the start value to determine whether the required period has elapsed.

See Using millis() for timing. A beginners guide for more details

I would make a simple millis timer that is reset every time the beam is broken OR made and set the timeout for twice as much as one open / close cycle + a few seconds. That way, if the hand were jammed, it would turn the servo OFF before it overheated and failed.