I’ve done a similar project. I’ll explain the method which I’ve used.
Normall we need hart beats/minute. So take the heart beat count for ten seconds and multiply it with 6.
Connect the input of HB sensor to any one of the input pin. Increment a count each time the pin become high from low. Generate a delay of 10 seconds by setting any one of the timer. (I hope you know the technique, using static variables for large delays). When it becomes 10 seconds, stop incrementing the count, read the count and multiply it with 6 and display.