Components and supplies
Arduino UNO
Perma-Proto Breadboard Half Size
Rotary potentiometer (generic)
Alligator Clips
Force Sensitive Resistor
Jumper wires (generic)
Standard LCD - 16x2 White on Blue
Breadboard (generic)
LED (generic)
Pushbutton switch 12mm
Tools and machines
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
CPR Feedback Code
arduino
1/* 2CPR feedback Test sketch 3-Using LCD to display results in real time 4 */ 5 6#include <LiquidCrystal.h> 7 8int pressurePin = 0; //pressure reading pin 9int pressureRead; //for reading pressure pin 10const int buttonPin = 8; // pin for CPR count 11unsigned long time; //to display time for compressions 12const int pressGood = 10; 13const int pressBad = 9; 14 15int BPM; //final output calculated beats per min 16float bpmCount; // to calculate BPM 17float cprCount = 0; // counter for the number of button presses, changed from int, changed from float 18int buttonState = 0; // current state of the button 19int lastButtonState = 0; // previous state of the button 20int cprTotal = 0; //total of the 5 stored values 21int cprCycle = 0; //keeps track of CPR cycle 22 23int timeSec, timeCPR, BPM_1; //calculating cpr time 24float totalTime; 25unsigned long timeBegin, timeEnd; 26 27LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //LCD pins 28 29void setup() { 30 31 pinMode(buttonPin, INPUT); //CPR button 32 pinMode(pressGood, OUTPUT); //for good release, led on Green 33 pinMode(pressBad, OUTPUT); // for bad release, led on Red 34 Serial.begin(9600); // start serial communication / uncomment to debug 35 Serial.println("Begin CPR"); 36 lcd.begin(16, 2); //start LCD 37 lcd.home(); 38 lcd.print("Begin CPR"); 39} 40 41void loop() { 42pressureRead = analogRead(pressurePin); 43 time = millis(); //start time 44 buttonState = digitalRead(buttonPin); 45 if (buttonState != lastButtonState) { 46 47 if (buttonState == HIGH) { //depth of at least 2in per AHA guidelines 48 lcd.clear(); 49 lcd.home(); 50 cprCount++; //add 1 to the running total 51 Serial.println(cprCount); 52 lcd.setCursor(0,0); 53 lcd.print("Count: "); 54 lcd.setCursor(7,0); 55 lcd.print(cprCount); 56 lcd.setCursor(10,0); 57 lcd.print("R: "); //rate BPM 58 59 if(cprCount == 1){ 60 timeBegin = millis(); //beginning time 61 } 62 63 } 64 65 } 66 //pressureRead = analogRead(pressurePin); 67 if (pressureRead < 500){ 68 digitalWrite(pressGood, HIGH); 69 digitalWrite(pressBad, LOW); 70 } 71 else if (pressureRead > 501){ 72 digitalWrite(pressBad, HIGH); 73 digitalWrite(pressGood, LOW); 74 } 75 76 77 78 if (cprCount == 30){ // 30:2 ratio for CPR, 30 total 79 cprCount = 0; //restart count 80 timeEnd = millis(); //capture end time for set 81 //Serial.println(timeEnd); 82 totalTime = (timeEnd - timeBegin) / 1000; //convert Ms to seconds 83 Serial.print("Total Time: "); 84 Serial.println(totalTime); 85 bpmCount = ( 30.0 / totalTime); //bpmCount = float 86 Serial.print("BPM Count: "); 87 Serial.println(bpmCount); 88 BPM = (bpmCount * 60.0); 89 Serial.print("Total time in sec: "); 90 Serial.println(totalTime); 91 lcd.home(); 92 lcd.print("Rate (BPM): "); 93 lcd.setCursor(12,0); 94 lcd.print(BPM); 95 Serial.print("BPM is: "); 96 Serial.println(BPM); 97 lcd.setCursor(0,1); 98 lcd.print("Total Time: "); 99 lcd.setCursor(12,1); 100 lcd.print(totalTime); 101 cprCycle++; 102 Serial.print("CPR Cycle #: "); 103 Serial.println(cprCycle); 104 if (cprCycle == 5){ 105 cprCycle = 0; 106 } 107 108 } 109 110 if (cprCount > 5 && cprCount <= 30) { 111 float rateTime = (millis() - timeBegin) / 1000; //changed int rateTime to unsigned long 112 //Serial.println(rateTime); 113 int rate = (cprCount / rateTime) * 60; //changed int to unsigned int 114 //Serial.print("BPM is: "); 115 //Serial.println(rate); 116 117 if (rate >= 100 && rate <= 120 ){ //AHA guidelines 100-120 CPM 118 lcd.setCursor(12,0); 119 lcd.print("Good"); 120 } 121 else { 122 lcd.setCursor(12,0); 123 lcd.print("----"); 124 } 125 } 126 127 128 // Delay 129 delay(25); //changed from 50 130 lastButtonState = buttonState; 131} 132 133 134
CPR Feedback Code
arduino
1/* 2CPR feedback Test sketch 3-Using LCD to display results in real 4 time 5 */ 6 7#include <LiquidCrystal.h> 8 9int pressurePin = 0; //pressure 10 reading pin 11int pressureRead; //for reading pressure pin 12const int buttonPin 13 = 8; // pin for CPR count 14unsigned long time; //to display time for compressions 15const 16 int pressGood = 10; 17const int pressBad = 9; 18 19int BPM; //final output calculated 20 beats per min 21float bpmCount; // to calculate BPM 22float cprCount = 0; // 23 counter for the number of button presses, changed from int, changed from float 24int 25 buttonState = 0; // current state of the button 26int lastButtonState = 27 0; // previous state of the button 28int cprTotal = 0; //total of the 5 stored 29 values 30int cprCycle = 0; //keeps track of CPR cycle 31 32int timeSec, timeCPR, 33 BPM_1; //calculating cpr time 34float totalTime; 35unsigned long timeBegin, timeEnd; 36 37LiquidCrystal 38 lcd(12, 11, 5, 4, 3, 2); //LCD pins 39 40void setup() { 41 42 pinMode(buttonPin, 43 INPUT); //CPR button 44 pinMode(pressGood, OUTPUT); //for good release, led on 45 Green 46 pinMode(pressBad, OUTPUT); // for bad release, led on Red 47 Serial.begin(9600); 48 // start serial communication / uncomment to debug 49 Serial.println("Begin CPR"); 50 51 lcd.begin(16, 2); //start LCD 52 lcd.home(); 53 lcd.print("Begin CPR"); 54} 55 56void 57 loop() { 58pressureRead = analogRead(pressurePin); 59 time = millis(); //start 60 time 61 buttonState = digitalRead(buttonPin); 62 if (buttonState != lastButtonState) 63 { 64 65 if (buttonState == HIGH) { //depth of at least 2in per AHA guidelines 66 67 lcd.clear(); 68 lcd.home(); 69 cprCount++; //add 1 to the running 70 total 71 Serial.println(cprCount); 72 lcd.setCursor(0,0); 73 lcd.print("Count: 74 "); 75 lcd.setCursor(7,0); 76 lcd.print(cprCount); 77 lcd.setCursor(10,0); 78 79 lcd.print("R: "); //rate BPM 80 81 if(cprCount == 1){ 82 83 timeBegin = millis(); //beginning time 84 } 85 86 } 87 88 89 } 90 //pressureRead = analogRead(pressurePin); 91 if (pressureRead 92 < 500){ 93 digitalWrite(pressGood, HIGH); 94 digitalWrite(pressBad, 95 LOW); 96 } 97 else if (pressureRead > 501){ 98 digitalWrite(pressBad, 99 HIGH); 100 digitalWrite(pressGood, LOW); 101 } 102 103 104 105 if 106 (cprCount == 30){ // 30:2 ratio for CPR, 30 total 107 cprCount = 0; //restart 108 count 109 timeEnd = millis(); //capture end time for set 110 //Serial.println(timeEnd); 111 112 totalTime = (timeEnd - timeBegin) / 1000; //convert Ms to seconds 113 114 Serial.print("Total Time: "); 115 Serial.println(totalTime); 116 117 bpmCount = ( 30.0 / totalTime); //bpmCount = float 118 Serial.print("BPM 119 Count: "); 120 Serial.println(bpmCount); 121 BPM = (bpmCount 122 * 60.0); 123 Serial.print("Total time in sec: "); 124 Serial.println(totalTime); 125 126 lcd.home(); 127 lcd.print("Rate (BPM): "); 128 lcd.setCursor(12,0); 129 130 lcd.print(BPM); 131 Serial.print("BPM is: "); 132 Serial.println(BPM); 133 134 lcd.setCursor(0,1); 135 lcd.print("Total Time: "); 136 137 lcd.setCursor(12,1); 138 lcd.print(totalTime); 139 cprCycle++; 140 141 Serial.print("CPR Cycle #: "); 142 Serial.println(cprCycle); 143 144 if (cprCycle == 5){ 145 cprCycle = 0; 146 } 147 148 149 } 150 151 if (cprCount > 5 && cprCount <= 30) { 152 153 float rateTime = (millis() - timeBegin) / 1000; //changed int rateTime 154 to unsigned long 155 //Serial.println(rateTime); 156 int rate = 157 (cprCount / rateTime) * 60; //changed int to unsigned int 158 //Serial.print("BPM 159 is: "); 160 //Serial.println(rate); 161 162 if (rate >= 163 100 && rate <= 120 ){ //AHA guidelines 100-120 CPM 164 lcd.setCursor(12,0); 165 166 lcd.print("Good"); 167 } 168 else { 169 lcd.setCursor(12,0); 170 171 lcd.print("----"); 172 } 173 } 174 175 176 // 177 Delay 178 delay(25); //changed from 50 179 lastButtonState = buttonState; 180} 181 182 183
Downloadable files
CPR Feedback Hardware Wiring Guide
CPR Feedback Hardware Wiring Guide
CPR Feedback Hardware Wiring Guide
CPR Feedback Hardware Wiring Guide
Documentation
LCD and LED Holder
STL file for LCD and LED holder
LCD and LED Holder
Comments
Only logged in users can leave comments
daescobar
0 Followers
•0 Projects
Table of contents
Intro
14
0