CSE371 (Introduction to Real-Time Embedded Systems) course project at Yanbu Industrial College. An Arduino-based heart rate monitor that reads a pulse sensor and shows the BPM on an LCD screen.
Team: Wejdan Aljohani, Rama Ayman
Heart-related diseases account for a large share of global deaths (nearly 30%, according to the studies we cited). Many pulse monitoring solutions are expensive, complicated, or don't give real-time data, which makes them hard to use widely.
A low-cost, easy-to-use heart rate monitor built on an Arduino Uno. The pulse sensor detects the heartbeat, the Arduino calculates the BPM in real time, and the result is shown on an LCD.
- Accurately measure heart rate
- Display the heart rate on an LCD
- Use a potentiometer to adjust the LCD contrast for better readability
- Arduino Uno with USB cable
- 9V battery
- 16x2 LCD
- 9V battery snap connector with DC jack
- Pulse sensor with wires
- Breadboard
- Potentiometer (LCD contrast)
- Jumper wires
- Pulse sensor: 5V, GND, and signal to analog pin A0
- LCD: connected to digital pins 2-7, powered from 5V and GND
- Potentiometer: outer pins to 5V and GND, middle pin to the LCD contrast pin
On startup the program initializes the LCD and pins and sets up a timer interrupt. The interrupt handler reads the pulse sensor every 2 ms and detects each heartbeat. The main loop checks a flag and, when a beat was found, shows the BPM on the LCD. If no beat is detected for more than 2.5 seconds, it times out.
BPM calculation: the time between two detected beats is the inter-beat interval (IBI) in milliseconds.
BPM = 60000 / IBI
The BPM is averaged over the last 10 beats to keep the reading stable.
-
Connect the pulse sensor to the Arduino and the breadboard
-
Connect the potentiometer to the breadboard
-
Connect the LCD to the breadboard and the Arduino
-
Connect the Arduino to the laptop with the USB cable
- Green ON LED: the Arduino is receiving power through the USB connection
- Yellow L LED: shows activity on digital pin 13, and may blink while the Arduino is running a program
-
Test: place a finger on the sensor and the heart rate appears on the LCD
void loop()
{
serialOutput();
if (QS == true) // A Heartbeat Was Found
{
// BPM and IBI have been Determined
// Quantified Self "QS" true when arduino finds a heartbeat
serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
QS = false; // reset the Quantified Self flag for next time
}
delay(20); // take a break
}
void interruptSetup()
{
// Initializes Timer2 to throw an interrupt every 2mS.
TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE
TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER
OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE
TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A
sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED
}void serialOutputWhenBeatHappens()
{
if (serialVisual == true) // Code to Make the Serial Monitor Visualizer Work
{
Serial.print(" Heart-Beat Found "); //ASCII Art Madness
Serial.print("BPM: ");
Serial.println(BPM);
lcd.print("Heart-Beat Found ");
lcd.setCursor(1,1);
lcd.print("BPM: ");
lcd.setCursor(5,1);
lcd.print(BPM);
delay(300);
lcd.clear();
}
else
{
sendDataToSerial('B',BPM); // send heart rate with a 'B' prefix
// ...Final system
Earlier test readings
| BPM 70 | BPM 68 |
|---|---|
![]() |
![]() |
With a finger on the sensor, the LCD shows "Heart-Beat Found" and the current BPM.
- Real-time embedded systems
- Arduino programming (C/C++)
- Timer interrupts
- Sensor interfacing
- LCD interfacing
- Circuit design
- Hardware testing
- Teamwork
- Technical documentation






