KY039 Arduino Heart rate code

sonyhome:
By bending the LED to face down onto the sensor, the fully lit sensor now reads in the 20's instead or mid 40's.
When I put my finger the signal is now in the 700's.

I've made a photo of my sensor. The main beam of the LED should be directed to the sensor to provide max IR intensity. That way I can even get value readings below 500 when putting my finger between LED and sensor.

sonyhome:
Overall the code could be simplified to just detect the light RAW and do the same max detectin on the RAW value instead of the math blurb done that generates a delta. No math, no floats, nothing...

It's interesting to see how many different codes can detect the heartrate. My solution would be much more complicated: Setting up a timer interrupt for sampling the signal to a FIFO buffer at a fixed interval, despite of what is going on at the same time (calculations, statistics, printing things on LCD). Then pulling the data from FIFO buffer and do all the calculations with sliding averages.