Learn how a heart beat sensor works
Doctors measure our heart rate manually. By holding our hands they feel the pulse in the nerve and look at their watch to count our heart beats per minute. Even we also can feel the pulse on our finger when our heart pumps blood into our blood vessels. This pulse is felt due to the expansion and contraction of blood vessel when blood enters and leaves it. Our heart does this around 72 to 84 times a minute for an healthy person.
What we do to measure the heart rate is, first we will detect the heart beat/pulse and count the pulses for one minute to get the beats per minute. So in order to detect the pulse we will pass light (using an LED) from one side of the finger and measure the intensity of light received on the other side (using an LDR). Whenever the heart pumps blood more light is absorbed by increased blood cells and we will observe a decrease in the intensity of light received on the LDR. As a result the resistance value of the LDR increases. This variation in resistance is converted into voltage variation using a signal conditioning circuit usually an OP-AMP. The signal is amplified enough to be detectable by the microcontroller inputs. The signal given to the microcontroller input will look somewhat like shown in the image above in a oscilloscope. The microcontroller can be programmed to receive an interrupt for every pulse detected and count the number of interrupts or pulses in a minute. The count value of pulses per minute will give you the Heart rate in bpm (Beats Per Minute).
Alternatively to save time, only the number of pulses for ten seconds are counted and then multiplied by 6 to get pulse count for 60 seconds/1 minute.