Use interrupt to determine a change in IR detector
You might need to apply hysteresis to OA2 - this has the effect of minimizing the effect of noise as the signal from OA1 gets close to the threshold point defined by R7. Try a 1k ohm in series with the signal from OA1 to non-inverting input of OA2 and something like a 100k to 1M ohm from output of OA2 back to its non-inverting input. The size of this feedback resistor will set the amount of hysteresis.