Pulse Checking Sensor Using Arduino Mega 2560

Introduction

In this article, I will explain about how to correctly check the pulse in our body and sense the correct pulse signal in mobile or system. We will perform this using Arduino Mega 2560.
 
Parts
  • Arduino Mega 2560 
  • Pulse sensor 
  • HookUp Wires 
Pulse sensor

 
Figure 1:
Pulse Sensor 
  • Pulse sensor is a plug-and-play heart-rate sensor for Arduino Mega 2560 
  • It can be used to check the pulse in our body.
  • It can be used by students, artists, and developers.  
Connection

In the pulse sensor they can have the 3 pin,
  • The first can be a negative pin connected to the Gnd of the Arduino Mega 2560.
  • The second can be a positive pin connected to the 5V of the Arduino Mega 2560. 
  • The third can be a input pin connected to the Analog pin A0 of the Arduino Mega 2560.  
Programming
  1. int pulsePin = 0;                 // Pulse Sensor purple wire connected to analog pin 0  
  2. int blinkPin = 13;                // pin to blink led at each beat  
  3. int fadePin = 5;                  // pin to do fancy classy fading blink at each beat  
  4. int fadeRate = 0;                 // used to fade LED on with PWM on fadePin  
  5.   
  6.   
  7. // these variables are volatile because they are used during the interrupt service routine!  
  8. volatile int BPM;                   // used to hold the pulse rate  
  9. volatile int Signal;                // holds the incoming raw data  
  10. volatile int IBI = 600;             // holds the time between beats, must be seeded!   
  11. volatile boolean Pulse = false;     // true when pulse wave is high, false when it's low  
  12. volatile boolean QS = false;        // becomes true when Arduoino finds a beat.  
  13.   
  14. void setup()  
  15. {  
  16.   pinMode(blinkPin,OUTPUT);         // pin that will blink to your heartbeat!  
  17.   pinMode(fadePin,OUTPUT);          // pin that will fade to your heartbeat!  
  18.   Serial.begin(115200);             // we agree to talk fast!  
  19.   interruptSetup();                 // sets up to read Pulse Sensor signal every 2mS   
  20.      
  21. }  
  22. void loop()  
  23. {  
  24.   sendDataToProcessing('S', Signal);     // send Processing the raw Pulse Sensor data  
  25.   if (QS == true)  
  26. {                                        // Quantified Self flag is true when arduino finds a heartbeat  
  27.         fadeRate = 255;                  // Set 'fadeRate' Variable to 255 to fade LED with pulse  
  28.         sendDataToProcessing('B',BPM);   // send heart rate with a 'B' prefix  
  29.         sendDataToProcessing('Q',IBI);   // send time between beats with a 'Q' prefix  
  30.         QS = false;                      // reset the Quantified Self flag for next time      
  31. }  
  32.  ledFadeToBeat();  
  33.     
  34.   delay(20);                             //  take a break  
  35. }  
  36.   
  37.   
  38. void ledFadeToBeat(){  
  39.     fadeRate -= 15;                         //  set LED fade value  
  40.     fadeRate = constrain(fadeRate,0,255);   //  keep LED fade value from going into negative numbers!  
  41.     analogWrite(fadePin,fadeRate);          //  fade LED  
  42.   }  
  43.   
  44.   
  45. void sendDataToProcessing(char symbol, int data ){  
  46.     Serial.print(symbol);                // symbol prefix tells Processing what type of data is coming  
  47.     Serial.println(data);                // the data to send culminating in a carriage return  
  48.   }  
Explanation
  • Check the pulse in monitor / smart mobile.
  • When the pulse is normal the LED blinks.
  • We can monitor the pulse with the correct data and symbol. 
Output

 
                           Figure 2: Output
 
Read more articles on Arduino: