The analog circuit around LM358 has 2 stages:
- a non-inverting amplifier, with A=((R13 + R12)/R1 +1), that uses the first opamp of LM358 (INA+, INA-, OUTA);
- a comparator with the second opamp (INB+, INB-, OUTB).
At OUTA the voltage is variable, so D7 will give a variable light in the heartbeat rythm. The comparator transforms the variable voltage in a square signal, so D5 will light at maximal intensity or will be off in the heartbeat rythm.
R14 sets the trigger level for the comparator and since the heartbeat voltage variation at OUTA can be in any range between 0...5V (depending on the finger opacity, thickness,...) R14 should be set for adequate triggering.
A Schmitt trigger, or positive feedback to introduce a little histeresis would be better, to avoid false detection.