Advertisement
pleasedontcode

**Heart Rate** rev_02

Feb 17th, 2025
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Heart Rate**
  13.     - Source Code NOT compiled for: Arduino Nano
  14.     - Source Code created on: 2025-02-17 16:42:41
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The system shall utilize the MAX30102 sensor to */
  21.     /* monitor heart rate and SpO2 levels, displaying */
  22.     /* data via I2C communication. */
  23. /****** SYSTEM REQUIREMENT 2 *****/
  24.     /* The system shall utilize the MAX30102 sensor to */
  25.     /* accurately monitor heart rate and SpO2 levels, */
  26.     /* transmitting data via I2C communication for real- */
  27.     /* time visualization. */
  28. /****** END SYSTEM REQUIREMENTS *****/
  29.  
  30. /* START CODE */
  31.  
  32. /****** DEFINITION OF LIBRARIES *****/
  33. #include <Wire.h>
  34. #include <max32664.h>   //https://github.com/Protocentral/protocentral-pulse-express
  35.  
  36. /****** FUNCTION PROTOTYPES *****/
  37. void setup(void);
  38. void loop(void);
  39.  
  40. /***** DEFINITION OF I2C PINS *****/
  41. const uint8_t srt_PIN_SDA_A4        = A4;
  42. const uint8_t srt_PIN_SCL_A5        = A5;
  43.  
  44. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  45. max32664 pulseSensor(srt_PIN_SDA_A4, srt_PIN_SCL_A5, RAWDATA_BUFFLEN); // Instantiate the MAX30102 sensor
  46.  
  47. void setup(void)
  48. {
  49.     // Initialize I2C communication
  50.     Wire.begin();
  51.    
  52.     // Initialize the MAX30102 sensor
  53.     if (pulseSensor.hubBegin() != CMD_SUCCESS) {
  54.         // Handle initialization error
  55.         while (1);
  56.     }
  57.    
  58.     // Additional setup code can be added here
  59. }
  60.  
  61. void loop(void)
  62. {
  63.     // Read heart rate and SpO2 data
  64.     if (pulseSensor.readSamples() == CMD_SUCCESS) {
  65.         // Process and visualize the data
  66.         // For example, you can print the values to the Serial Monitor
  67.         Serial.print("Heart Rate: ");
  68.         Serial.println(pulseSensor.max32664Output.hr);
  69.         Serial.print("SpO2: ");
  70.         Serial.println(pulseSensor.max32664Output.spo2);
  71.     }
  72.    
  73.     // Add a delay for readability
  74.     delay(1000);
  75. }
  76.  
  77. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement