Simulating a Heart Rate Monitoring System with Alert
Objective:
Students will design and simulate a heart rate monitoring system using a simulated sensor to detect the
heart rate. When the heart rate exceeds a predefined threshold, an alert will be triggered (simulated
with an LED or buzzer). This exercise introduces students to health monitoring systems and alert
mechanisms.
Requirements:
Laptop with internet access
Free account on Tinkercad or Wokwi
Basic knowledge of Arduino programming
Understanding of health monitoring systems
Step-by-Step Instructions:
1. Setup the Simulation Environment (5 minutes):
Log in to Tinkercad or Wokwi.
Create a new Arduino project.
2. Design the Heart Rate Monitoring System (10 minutes):
Drag and drop the following components into the simulation workspace:
o Arduino Uno
o Simulated Heart Rate Sensor (can be represented by a potentiometer to simulate heart
rate fluctuations)
o LED (to simulate the alert or a visual indicator)
o Buzzer (optional, to simulate the alert sound)
o Resistor (for the LED and buzzer)
o Breadboard (optional, depending on the simulator)
Wire the components:
o Connect the Heart Rate Sensor (simulated with a potentiometer) to an analog input pin
(e.g., pin A0).
o Connect the LED to a digital output pin (e.g., pin 9) and ground, with a resistor (220Ω) to
limit current.
o Connect the Buzzer to a digital pin (e.g., pin 10) and ground (optional).
3. Program the Arduino (20 minutes):
Open the code editor in the simulator and use the following code for the heart rate monitoring
system:
cpp
CopyEdit
#define HEART_RATE_SENSOR_PIN A0 // Pin connected to the heart rate sensor (simulated with
potentiometer)
#define ALERT_LED_PIN 9 // Pin connected to the LED (alert visual indicator)
#define BUZZER_PIN 10 // Pin connected to the buzzer (alert sound)
int heartRateValue = 0; // Variable to store heart rate sensor value
int threshold = 100; // Threshold for heart rate (bpm, adjustable)
void setup() {
pinMode(ALERT_LED_PIN, OUTPUT); // Set the LED pin as output
pinMode(BUZZER_PIN, OUTPUT); // Set the buzzer pin as output
Serial.begin(9600); // Start serial communication for debugging
void loop() {
// Read the heart rate value from the sensor (simulated with potentiometer)
heartRateValue = analogRead(HEART_RATE_SENSOR_PIN);
// Convert the sensor value to heart rate (simulated scaling)
int heartRate = map(heartRateValue, 0, 1023, 60, 150); // Mapping sensor value to heart rate range (60-
150 bpm)
// Print the heart rate value to the serial monitor for debugging
Serial.print("Heart Rate: ");
Serial.println(heartRate);
// Check if the heart rate exceeds the threshold and trigger an alert
if (heartRate > threshold) {
digitalWrite(ALERT_LED_PIN, HIGH); // Turn on the LED to indicate alert
digitalWrite(BUZZER_PIN, HIGH); // Turn on the buzzer to indicate alert
Serial.println("Alert! Heart rate exceeded threshold.");
} else {
digitalWrite(ALERT_LED_PIN, LOW); // Turn off the LED
digitalWrite(BUZZER_PIN, LOW); // Turn off the buzzer
delay(500); // Delay for half a second before reading again
Explanation of the Code:
The Heart Rate Sensor (simulated with a potentiometer) is used to read values that represent
heart rate fluctuations.
The value from the potentiometer is mapped to a range of heart rate values (e.g., 60–150 bpm).
If the heart rate exceeds the predefined threshold (e.g., 100 bpm), the system triggers an alert
by turning on an LED and activating a buzzer.
The Serial Monitor prints the current heart rate value for debugging.
4. Run and Test (15 minutes):
Start the simulation.
Adjust the potentiometer to simulate changes in heart rate (e.g., slowly increase or decrease the
potentiometer value).
Observe the LED turning on and the buzzer sounding when the heart rate exceeds the threshold.
Verify that the system deactivates the alert when the heart rate goes back below the threshold.
5. Discussion and Reflection (10 minutes):
Real-Time Monitoring:
Discuss how this system simulates a real-time health monitoring process. Real-world systems like
heart rate monitors or fitness trackers often use similar principles to measure and alert users
about potential health risks, such as tachycardia (rapid heart rate).
Threshold Adjustment:
Discuss how heart rate thresholds should be personalized depending on the individual’s health
status, age, or fitness level. For example, a threshold of 100 bpm may be high for some
individuals but normal for others.
Importance of Alerts in Health Systems:
Reflect on the role of alerts in health systems. Early alerts can help prevent critical conditions by
warning individuals to take immediate action, such as seeking medical attention or performing a
stress-relieving activity.
Extensions:
Suggest possible extensions to the system:
o Use a real heart rate sensor (e.g., pulse sensor) instead of the potentiometer to read
actual heart rate values.
o Implement multiple thresholds for different alert levels (e.g., yellow alert for mild
elevation, red alert for dangerous heart rates).
o Integrate a screen (e.g., LCD) to display the current heart rate.
o Implement an IoT solution where heart rate data can be sent to a smartphone or a web
application for real-time monitoring.
This exercise introduces students to health monitoring systems and teaches them how to handle real-
time sensor data. It can be further extended to simulate more complex medical devices or systems,
making it highly relevant for applications in health and fitness technology.