Connecting Pulse Sensor With Android App Using Arduino Mega 2560

Introduction

  • In this article, I will explain about connecting the Pulse Sensor with Android App with Arduino Mega2560.
  • It can be used to give the correct information on the mobile App.
Parts of lists
  • Arduino Mega 2560
  • Pulse Sensor
  • Bluetooth
  • Hook Up wires
  • Bread Boards 
Pulse Sensor
  • It can be used to check the pulse of the body.
  • It can be user friendly and can be used by students, artists, and developers.
  • It can be called the plug-play.
     
     
     Figure 1: Pulse Sensor
Connection
 
Step 1 Connection from Pulse Sensor to Arduino Mega 2560
  • They can commonly have three pins.
  • The first pin can be connected to the gnd pin of the Arduino Mega 2560.
  • The second pin can be connected to the vcc of the 5v of ArduinoMega 2560.
  • The third can be connected to the vin of the Analog pin of the Ao of Arduino Mega 2560.
Step 2 Connection From Bluetooth to the Arduino Mega 2560
  • Connect the vcc pin to the 5v of the Arduino Mega 2560.
  • Connect the gnd pin to the gnd of the Arduino Mega 2560.
  • Connect the Tx pin to the RX.
  • Connect the RX pin to the TX.
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. // Volatile Variables, used in the interrupt service routine!      
  7. volatile int BPM; // int that holds raw Analog in 0. updated every 2mS      
  8. volatile int Signal; // holds the incoming raw data      
  9. volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!       
  10. volatile boolean Pulse = false// "True" when User's live heartbeat is detected. "False" when not a "live beat".       
  11. volatile boolean QS = false// becomes true when Arduoino finds a beat.      
  12.     
  13. // Regards Serial OutPut  -- Set This Up to your needs      
  14. static boolean serialVisual = true// Set to 'false' by Default.  Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse       
  15.     
  16.     
  17. void setup()    
  18. {    
  19.     pinMode(blinkPin, OUTPUT); // pin that will blink to your heartbeat!      
  20.     pinMode(fadePin, OUTPUT); // pin that will fade to your heartbeat!      
  21.     Serial.begin(115200); // we agree to talk fast!      
  22.     interruptSetup(); // sets up to read Pulse Sensor signal every 2mS       
  23.     //   analogReference(EXTERNAL);         
  24.     Genotronex.begin(9600);    
  25.     Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");    
  26.     pinMode(ledpin, OUTPUT);    
  27. }    
  28.     
  29.     
  30. //  Where the Magic Happens      
  31. void loop()    
  32. {    
  33.     
  34.     serialOutput();    
  35.     
  36.     if (QS == true)     
  37.     { //  A Heartbeat Was Found      
  38.         // BPM and IBI have been Determined      
  39.         // Quantified Self "QS" true when arduino finds a heartbeat      
  40.         digitalWrite(blinkPin, HIGH); // Blink LED, we got a beat.       
  41.         fadeRate = 255; // Makes the LED Fade Effect Happen      
  42.         // Set 'fadeRate' Variable to 255 to fade LED with pulse      
  43.         serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.           
  44.         QS = false// reset the Quantified Self flag for next time          
  45.     } else     
  46.     {    
  47.     
  48.         digitalWrite(blinkPin, LOW); // There is not beat, turn off pin 13 LED      
  49.     }    
  50.     
  51.     ledFadeToBeat(); // Makes the LED Fade Effect Happen       
  52.     if (Genotronex.available())     
  53.     {    
  54.         BluetoothData = Genotronex.read();    
  55.         if (BluetoothData == '1')     
  56.         {     
  57.             // if number 1 pressed ....      
  58.             digitalWrite(ledpin, 1);    
  59.             Genotronex.println("LED  On D12 ON ! ");    
  60.         }    
  61.         if (BluetoothData == '0')     
  62.         {     
  63.             // if number 0 pressed ....      
  64.             digitalWrite(ledpin, 0);    
  65.             Genotronex.println("LED  On D12 Off ! ");    
  66.         }    
  67.     }    
  68.     delay(20); //  take a break      
  69. }   
Explanation
  • In this article, I clearly explained about the Pulse Sensor
  • It can be clearly explained in the Bluetooth app.
  • When the pulse is low, it cannot blink led
  • When the pulse is high, it can blink led.