David Escobar
Published © GPL3+

Arduino Powered CPR Feedback Device

Adding real-time feedback to a CPR manikin. Allows for depth, rate, time and chest recoil monitoring.

IntermediateShowcase (no instructions)20,350
Arduino Powered CPR Feedback Device

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
Breadboard (generic)
Breadboard (generic)
×1
Adafruit Force Sensitive Resistor
×1
LED (generic)
LED (generic)
×2
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Alligator Clips
Alligator Clips
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Perma-Proto Breadboard Half Size
Perma-Proto Breadboard Half Size
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

LCD and LED Holder

STL file for LCD and LED holder

Schematics

CPR Feedback Hardware Wiring Guide

Code

CPR Feedback Code

Arduino
/*
CPR feedback Test sketch
-Using LCD to display results in real time
 */

#include <LiquidCrystal.h>

int pressurePin = 0; //pressure reading pin
int pressureRead; //for reading pressure pin
const int buttonPin = 8;  // pin for CPR count
unsigned long time; //to display time for compressions
const int pressGood = 10;
const int pressBad =  9;

int BPM; //final output calculated beats per min
float bpmCount; // to calculate BPM
float cprCount = 0;   // counter for the number of button presses, changed from int, changed from float
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button
int cprTotal = 0; //total of the 5 stored values
int cprCycle = 0; //keeps track of CPR cycle

int  timeSec, timeCPR, BPM_1; //calculating cpr time
float totalTime;
unsigned long timeBegin, timeEnd;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //LCD pins

void setup() {
 
  pinMode(buttonPin, INPUT); //CPR button
  pinMode(pressGood, OUTPUT); //for good release, led on Green
  pinMode(pressBad, OUTPUT); // for bad release, led on Red
  Serial.begin(9600); // start serial communication / uncomment to debug
  Serial.println("Begin CPR");
  lcd.begin(16, 2); //start LCD
  lcd.home();
  lcd.print("Begin CPR");
}

void loop() {
pressureRead = analogRead(pressurePin);
  time = millis(); //start time
  buttonState = digitalRead(buttonPin);
  if (buttonState != lastButtonState) {
       
    if (buttonState == HIGH) { //depth of at least 2in per AHA guidelines
      lcd.clear();
      lcd.home();
      cprCount++; //add 1 to the running total
      Serial.println(cprCount);
      lcd.setCursor(0,0);
      lcd.print("Count: ");
      lcd.setCursor(7,0);
      lcd.print(cprCount);
      lcd.setCursor(10,0);
      lcd.print("R: ");     //rate BPM
      
      if(cprCount == 1){
         timeBegin = millis(); //beginning time
      }
      
      }
     
    }
    //pressureRead = analogRead(pressurePin);
    if (pressureRead < 500){
        digitalWrite(pressGood, HIGH);
        digitalWrite(pressBad, LOW);
    }
    else if (pressureRead > 501){
        digitalWrite(pressBad, HIGH);
        digitalWrite(pressGood, LOW);
    }



     if (cprCount == 30){ // 30:2 ratio for CPR, 30 total
            cprCount = 0; //restart count
            timeEnd = millis(); //capture end time for set
            //Serial.println(timeEnd);
            totalTime = (timeEnd - timeBegin) / 1000; //convert Ms to seconds
            Serial.print("Total Time: ");
            Serial.println(totalTime);
            bpmCount = ( 30.0 / totalTime); //bpmCount = float
            Serial.print("BPM Count: ");
            Serial.println(bpmCount);
            BPM = (bpmCount * 60.0);
            Serial.print("Total time in sec: ");
            Serial.println(totalTime);
            lcd.home();
            lcd.print("Rate (BPM): ");
            lcd.setCursor(12,0);
            lcd.print(BPM);
            Serial.print("BPM is: ");
            Serial.println(BPM);
            lcd.setCursor(0,1);
            lcd.print("Total Time: ");
            lcd.setCursor(12,1);
            lcd.print(totalTime);
            cprCycle++;
            Serial.print("CPR Cycle #: ");
            Serial.println(cprCycle);
            if (cprCycle == 5){
                cprCycle = 0;
            }
            
     }
     
     if (cprCount > 5 && cprCount <= 30) {
         float rateTime = (millis() - timeBegin) / 1000; //changed int rateTime to unsigned long
         //Serial.println(rateTime);
         int rate = (cprCount / rateTime) * 60; //changed int to unsigned int
         //Serial.print("BPM is: ");
         //Serial.println(rate);
         
         if (rate >= 100 && rate <= 120 ){ //AHA guidelines 100-120 CPM
             lcd.setCursor(12,0);
             lcd.print("Good");
         }
         else {
             lcd.setCursor(12,0);
             lcd.print("----");
         }
     }

     
    // Delay
    delay(25); //changed from 50
  lastButtonState = buttonState;
}

Credits

David Escobar

David Escobar

7 projects • 44 followers
Healthcare Simulation Specialist. 9+ years in healthcare.I have been actively involved with 3D printing and electronics for the past 2 years

Comments