How do I use the KY-039 sensor?

Hi!! I see this code only works for detecting the heartbeat but i want to calculate heart rate.Can you please suggest me the code