Heart Rate Calculator

I programmed the Commodore 64 to compute a pulse rate from a series of keystrokes. The instructions were "press enter with each heartbeat". The character ROM had a ♥ character that I blinked red with each keystroke.

Uploaded image

I measured the interval between keystrokes. If this was more than a couple of seconds I ignored this sample.

I averaged good samples with previous intervals taking, say, 9/10 old and 1/10 new.

I converted the moving average interval to a pulse rate by inverting and scaling by 60,000 msec per minute.

I replicated the program a few years later in javascript. See that page This code is bound to the "pulse" button's onClick attribute.

o = n; n = (new Date()).getTime(); if (n-o < 2000) { p = .9*p + .1*(n-o); pulse.value = Math.round(60000/p); }