KY039 Arduino Heart rate code

Sensor is well connected, do you know why I am getting data around 1023 plz?

I will ask one more time then I am going to give up if you don't provide details.

Exactly how is it connected ? Which sensor pin to which Arduino pin ? The larger picture tells us nothing. For instance, have you got the sensor analogue pin connected to Arduino A0 or Arduino pin 0 ?

If you have got the wiring right then have you tried shielding the whole sensor to prevent ambient light affecting the reading ? I assume that you are actually putting your finger between the LED and the sensor in the first place.