Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Heartbeat Monitor with I2C LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino Heartbeat Monitor with I2C LCD Display

Heartbeat Monitoring Circuit Documentation

Summary

This document provides a detailed overview of a heartbeat monitoring circuit. The circuit consists of an Arduino UNO microcontroller, a 16x2 I2C LCD display, and a heart pulse sensor. The Arduino UNO reads the pulse sensor data and displays the heartbeat rate (BPM) on the LCD. Additionally, an LED is used to indicate heartbeat detection.

Component List

Arduino UNO

16x2 I2C LCD

Heart Pulse Sensor

Wiring Details

Arduino UNO

16x2 I2C LCD

Heart Pulse Sensor

Code Documentation

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust if necessary
const int sensorPin = A0;      // Pulse sensor input
const int enableButton = 2;    // Button input for AND gate
const int ledPin = 13;         // LED output via OR gate
const int threshold = 550;     // Threshold for pulse detection

int bpm = 0;
int lastReading = 0;
int currentReading = 0;
unsigned long lastBeatTime = 0;
bool heartbeatDetected = false;

void setup() {
  lcd.begin(16, 2);
  lcd.backlight();
  lcd.print("Heartbeat Monitor");
  
  pinMode(sensorPin, INPUT);
  pinMode(enableButton, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // Read pulse sensor
  currentReading = analogRead(sensorPin);
  heartbeatDetected = (currentReading > threshold && lastReading <= threshold);

  if (heartbeatDetected) {
    unsigned long currentTime = millis();
    if (lastBeatTime != 0) {
      int beatInterval = currentTime - lastBeatTime;
      bpm = 60000 / beatInterval;
    }
    lastBeatTime = currentTime;
    digitalWrite(ledPin, HIGH); // OR gate LED indication

    // AND gate for LCD display
    if (digitalRead(enableButton) == LOW) {
      lcd.setCursor(0, 1);
      lcd.print("BPM: ");
      lcd.print(bpm);
    }
  } else {
    digitalWrite(ledPin, LOW);
  }

  lastReading = currentReading;
  delay(10); // Smooth signal
}

This code initializes the LCD and sets up the necessary pins for the pulse sensor, button, and LED. In the main loop, it reads the pulse sensor data, detects heartbeats, calculates the BPM, and updates the LCD and LED accordingly. The button is used to enable or disable the BPM display on the LCD.