Components and supplies
Alphanumeric LCD, 16 x 2
Single Turn Potentiometer- 10k ohms
Resistor 330 ohm
Arduino UNO
5 mm LED: Green
Pulse Sensor
Jumper wires (generic)
Tools and machines
Hot glue gun (generic)
CardBoard
Apps and platforms
Arduino IDE
Project description
Code
Code
arduino
1// https://www.youtube.com/channel/UCaXI2PcsTlH5g0et67kdD6g // 2// HeartBeat / Pulse Monitoring Device // 3// By MOHD SOHAIL // 4 5 6#define USE_ARDUINO_INTERRUPTS true //--> Set-up low-level interrupts for most acurate BPM math. 7#include <PulseSensorPlayground.h> //--> Includes the PulseSensorPlayground Library. 8#include <LiquidCrystal.h> //--> Includes the LiquidCrystal Library. 9 10LiquidCrystal lcd(2, 3, 8, 9, 10, 11); //--> Initialize LiquidCrystal with "lcd". lcd(RS,E,D4,D5,D6,D7). 11 12 13const int PulseWire = A0; //--> PulseSensor PURPLE WIRE connected to ANALOG PIN 0 14const int LED_3 = 13; //--> LED to detect when the heart is beating. The LED is connected to PIN 3 on the Arduino UNO. 15int Threshold = 550; //--> Determine which Signal to "count as a beat" and which to ignore. 16 //--> Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting. 17 //--> Otherwise leave the default "550" value. 18 19 20//----------------------------------------Draw "Heart" on LCD. 21/* 22 heart4 heart5 23 === === 24 25 = 00011 11000 00011 11000 = 11 11 11 11 26 00111 11100 00111 11100 111 111 111 111 27 01111 11110 01111 11110 1111 1111 1111 1111 28 11111 11111 11111 11111 11111 11111 11111 11111 29 heart3 11111 11111 11111 11111 heart6 11111 11111 11111 11111 30 11111 11111 11111 11111 11111 11111 11111 11111 31 11111 11111 11111 11111 11111 11111 11111 11111 32 = 01111 11111 11111 11110 = 1111 11111 11111 1111 33 -------> 34 = 00011 11111 11111 11000 = 11 11111 11111 11 35 00001 11111 11111 10000 1 11111 11111 1 36 00000 11111 11111 00000 11111 11111 37 heart2 00000 11111 11111 00000 heart7 11111 11111 38 00000 01111 11110 00000 1111 1111 39 00000 00111 11100 00000 111 111 40 00000 00011 11000 00000 11 11 41 = 00000 00001 10000 00000 = 1 1 42 43 === === 44 heart1 heart8 45 46*/ 47 48byte heart1[8] = {B11111, B11111, B11111, B11111, B01111, B00111, B00011, B00001}; 49byte heart2[8] = {B00011, B00001, B00000, B00000, B00000, B00000, B00000, B00000}; 50byte heart3[8] = {B00011, B00111, B01111, B11111, B11111, B11111, B11111, B01111}; 51byte heart4[8] = {B11000, B11100, B11110, B11111, B11111, B11111, B11111, B11111}; 52byte heart5[8] = {B00011, B00111, B01111, B11111, B11111, B11111, B11111, B11111}; 53byte heart6[8] = {B11000, B11100, B11110, B11111, B11111, B11111, B11111, B11110}; 54byte heart7[8] = {B11000, B10000, B00000, B00000, B00000, B00000, B00000, B00000}; 55byte heart8[8] = {B11111, B11111, B11111, B11111, B11110, B11100, B11000, B10000}; 56//---------------------------------------- 57 58int Instructions_view = 500; //--> Variable for waiting time to display instructions on LCD. 59 60PulseSensorPlayground pulseSensor; //--> Creates an instance of the PulseSensorPlayground object called "pulseSensor" 61 62 63void setup() { 64 Serial.begin(9600);//--> Set's up Serial Communication at certain speed. 65 lcd.begin(16, 2); //--> Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display 66 67 68 lcd.createChar(1, heart1); 69 lcd.createChar(2, heart2); 70 lcd.createChar(3, heart3); 71 lcd.createChar(4, heart4); 72 lcd.createChar(5, heart5); 73 lcd.createChar(6, heart6); 74 lcd.createChar(7, heart7); 75 lcd.createChar(8, heart8); 76 77 78 79 lcd.setCursor(0,0); 80 lcd.print("Heart Beat/Pulse"); 81 lcd.setCursor(0,1); 82 lcd.print(" Monitoring EIF "); 83 delay(2000); 84 85 86 pulseSensor.analogInput(PulseWire); 87 pulseSensor.blinkOnPulse(LED_3); //--> auto-magically blink Arduino's LED with heartbeat. 88 pulseSensor.setThreshold(Threshold); 89 90 91 92 if (pulseSensor.begin()) { 93 Serial.println("We created a pulseSensor Object !"); //--> This prints one time at Arduino power-up, or on Arduino reset. 94 } 95 96 97 delay(2000); 98 lcd.clear(); 99} 100 101 102 103void loop() { 104 int myBPM = pulseSensor.getBeatsPerMinute(); //--> Calls function on our pulseSensor object that returns BPM as an "int". "myBPM" hold this BPM value now. 105 106 107 if (Instructions_view < 500) { 108 Instructions_view++; 109 } 110 111 if (Instructions_view > 499) { 112 lcd.setCursor(0,0); 113 lcd.print("Put your finger "); 114 lcd.setCursor(0,1); 115 lcd.print(" on the sensor "); 116 delay(1000); 117 lcd.clear(); 118 delay(500); 119 } 120 121 122 if (pulseSensor.sawStartOfBeat()) { //--> If test is "true", then the following conditions will be executed. 123 Serial.println(" A HeartBeat Happened ! "); //--> Print a message "a heartbeat happened". 124 Serial.print("BPM: "); //--> Print phrase "BPM: " 125 Serial.println(myBPM); //--> Print the value inside of myBPM. 126 127 128 129 lcd.setCursor(1,1); 130 lcd.write(byte(1)); 131 lcd.setCursor(0,1); 132 lcd.write(byte(2)); 133 lcd.setCursor(0,0); 134 lcd.write(byte(3)); 135 lcd.setCursor(1,0); 136 lcd.write(byte(4)); 137 lcd.setCursor(2,0); 138 lcd.write(byte(5)); 139 lcd.setCursor(3,0); 140 lcd.write(byte(6)); 141 lcd.setCursor(3,1); 142 lcd.write(byte(7)); 143 lcd.setCursor(2,1); 144 lcd.write(byte(8)); 145 146 147 148 lcd.setCursor(5,0); 149 lcd.print("Heart Rate"); 150 lcd.setCursor(5,1); 151 lcd.print(": "); 152 lcd.print(myBPM); 153 lcd.print(" "); 154 lcd.print("BPM "); 155 156 157 Instructions_view = 0; 158 } 159 160 161 delay(20); //--> considered best practice in a simple sketch. 162} 163
Downloadable files
Circuit Diagram
Circuit Diagram
Circuit Diagram
Circuit Diagram
Comments
Only logged in users can leave comments