/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: **Heart Sensor**
- Source Code NOT compiled for: Arduino Nano
- Source Code created on: 2025-02-17 16:39:31
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* The system shall utilize the MAX30102 sensor to */
/* monitor heart rate and SpO2 levels, displaying */
/* data via I2C communication. */
/****** END SYSTEM REQUIREMENTS *****/
/* START CODE */
/****** DEFINITION OF LIBRARIES *****/
#include
#include //https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF I2C PINS *****/
const uint8_t srt_PIN_SDA_A4 = A4;
const uint8_t srt_PIN_SCL_A5 = A5;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
MAX30105 particleSensor; // Create an instance of the MAX30105 class
void setup(void)
{
// Initialize I2C communication
Wire.begin(srt_PIN_SDA_A4, srt_PIN_SCL_A5);
// Initialize the MAX30105 sensor
if (!particleSensor.begin(Wire, I2C_SPEED_STANDARD)) {
Serial.println("MAX30105 not found. Please check wiring.");
while (1); // Halt execution if sensor not found
}
// Setup the sensor with desired settings
particleSensor.setup(); // Configure the sensor with default settings
}
void loop(void)
{
// Read heart rate and SpO2 values
uint32_t redValue = particleSensor.getRed();
uint32_t irValue = particleSensor.getIR();
// Process and display the values (this is a placeholder for actual display code)
Serial.print("Red: ");
Serial.print(redValue);
Serial.print(" IR: ");
Serial.println(irValue);
// Add a delay to avoid flooding the serial output
delay(1000); // Delay for 1 second before the next reading
}
/* END CODE */