Heart Rate Monitor

beats maintins a count of the number of heartbeats, keeps counting for as along as your heart is beating. the code only wants to know that at least two beats have occured so it can caluclate the period since the last beat, so you could replace it with a flag if you wanted to.

period is the variable holding the duration of the last heartbeat. The sketch should really disable interrupts when this value is used.

as I said, the code above is off the top of my head, but I hope it gives you some ideas.