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. // Volatile Variables, used in the interrupt service routine!
  6. volatile int BPM; // int that holds raw Analog in 0. updated every 2mS
  7. volatile int Signal; // holds the incoming raw data
  8. volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!
  9. volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not a "live beat".
  10. volatile boolean QS = false; // becomes true when Arduoino finds a beat.
  11. // Regards Serial OutPut -- Set This Up to your needs
  12. static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse
  13. void setup()
  14. {
  15. pinMode(blinkPin, OUTPUT); // pin that will blink to your heartbeat!
  16. pinMode(fadePin, OUTPUT); // pin that will fade to your heartbeat!
  17. Serial.begin(115200); // we agree to talk fast!
  18. interruptSetup(); // sets up to read Pulse Sensor signal every 2mS
  19. // analogReference(EXTERNAL);
  20. Genotronex.begin(9600);
  21. Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");
  22. pinMode(ledpin, OUTPUT);
  23. }
  24. // Where the Magic Happens
  25. void loop()
  26. {
  27. serialOutput();
  28. if (QS == true)
  29. { // A Heartbeat Was Found
  30. // BPM and IBI have been Determined
  31. // Quantified Self "QS" true when arduino finds a heartbeat
  32. digitalWrite(blinkPin, HIGH); // Blink LED, we got a beat.
  33. fadeRate = 255; // Makes the LED Fade Effect Happen
  34. // Set 'fadeRate' Variable to 255 to fade LED with pulse
  35. serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
  36. QS = false; // reset the Quantified Self flag for next time
  37. } else
  38. {
  39. digitalWrite(blinkPin, LOW); // There is not beat, turn off pin 13 LED
  40. }
  41. ledFadeToBeat(); // Makes the LED Fade Effect Happen
  42. if (Genotronex.available())
  43. {
  44. BluetoothData = Genotronex.read();
  45. if (BluetoothData == '1')
  46. {
  47. // if number 1 pressed ....
  48. digitalWrite(ledpin, 1);
  49. Genotronex.println("LED On D12 ON ! ");
  50. }
  51. if (BluetoothData == '0')
  52. {
  53. // if number 0 pressed ....
  54. digitalWrite(ledpin, 0);
  55. Genotronex.println("LED On D12 Off ! ");
  56. }
  57. }
  58. delay(20); // take a break
  59. }
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.