Advertisement
pleasedontcode

**Heart Sensor** rev_01

Feb 17th, 2025
102
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 Sensor**
  13.     - Source Code NOT compiled for: Arduino Nano
  14.     - Source Code created on: 2025-02-17 16:39:31
  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. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /* START CODE */
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <Wire.h>
  29. #include <MAX30105.h>   //https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF I2C PINS *****/
  36. const uint8_t srt_PIN_SDA_A4        = A4;
  37. const uint8_t srt_PIN_SCL_A5        = A5;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. MAX30105 particleSensor; // Create an instance of the MAX30105 class
  41.  
  42. void setup(void)
  43. {
  44.     // Initialize I2C communication
  45.     Wire.begin(srt_PIN_SDA_A4, srt_PIN_SCL_A5);
  46.    
  47.     // Initialize the MAX30105 sensor
  48.     if (!particleSensor.begin(Wire, I2C_SPEED_STANDARD)) {
  49.         Serial.println("MAX30105 not found. Please check wiring.");
  50.         while (1); // Halt execution if sensor not found
  51.     }
  52.    
  53.     // Setup the sensor with desired settings
  54.     particleSensor.setup(); // Configure the sensor with default settings
  55. }
  56.  
  57. void loop(void)
  58. {
  59.     // Read heart rate and SpO2 values
  60.     uint32_t redValue = particleSensor.getRed();
  61.     uint32_t irValue = particleSensor.getIR();
  62.    
  63.     // Process and display the values (this is a placeholder for actual display code)
  64.     Serial.print("Red: ");
  65.     Serial.print(redValue);
  66.     Serial.print(" IR: ");
  67.     Serial.println(irValue);
  68.    
  69.     // Add a delay to avoid flooding the serial output
  70.     delay(1000); // Delay for 1 second before the next reading
  71. }
  72.  
  73. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement