This calculator helps you determine your heart rate from an electrocardiogram (EKG) by measuring the time between R-waves (the peak of the QRS complex). There are a few common methods, and this calculator demonstrates the most straightforward one: counting the small boxes.
.calculator-container {
font-family: sans-serif;
max-width: 500px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.input-section, .button-section, .result-section {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="number"] {
width: calc(100% – 22px);
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
.result-section {
font-weight: bold;
color: #333;
background-color: #f9f9f9;
padding: 10px;
border: 1px solid #eee;
border-radius: 4px;
}
function calculateEKGHeartRate() {
var smallBoxesInput = document.getElementById("smallBoxes");
var resultDiv = document.getElementById("result");
var smallBoxes = parseFloat(smallBoxesInput.value);
if (isNaN(smallBoxes) || smallBoxes <= 0) {
resultDiv.innerHTML = "Please enter a valid number of small boxes (greater than 0).";
return;
}
// Standard EKG paper has 25 small boxes per second (if speed is 25 mm/s)
// And each small box represents 0.04 seconds.
// Heart rate = 1500 / number of small boxes between R-waves (for a rate per minute)
var heartRate = 1500 / smallBoxes;
resultDiv.innerHTML = "Estimated Heart Rate: " + heartRate.toFixed(2) + " bpm";
}