Advertisement
pleasedontcode

"Sensors Monitoring" rev_23

Dec 22nd, 2023
80
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: "Sensors Monitoring"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-22 15:24:47
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* if distance is less than 20cm so read heart rate. */
  21.     /* If heart rate is above 100bpm so print on serial */
  22.     /* "HUMAN STRESSED". */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h>
  27. #include <Wire.h>
  28. #include <Ultrasonic.h>
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33. int readHeartRate();
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t frontSensor_HC_SR04_Echo_PIN_D4 = 4;
  37. const uint8_t sensor_MAX30100_INT_PIN_D5 = 5;
  38.  
  39. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  40. const uint8_t alarm_ActiveBuzzer_output_PIN_D2 = 2;
  41. const uint8_t frontSensor_HC_SR04_Trigger_PIN_D3 = 3;
  42.  
  43. /***** DEFINITION OF I2C PINS *****/
  44. const uint8_t sensor_MAX30100_I2C_PIN_SDA_A4 = A4;
  45. const uint8_t sensor_MAX30100_I2C_PIN_SCL_A5 = A5;
  46. const uint8_t sensor_MAX30100_I2C_SLAVE_ADDRESS = 0x57;
  47.  
  48. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  49. Ultrasonic ultrasonic(frontSensor_HC_SR04_Trigger_PIN_D3, frontSensor_HC_SR04_Echo_PIN_D4);
  50.  
  51. void setup(void)
  52. {
  53.   pinMode(frontSensor_HC_SR04_Echo_PIN_D4, INPUT);
  54.   pinMode(sensor_MAX30100_INT_PIN_D5, INPUT_PULLUP);
  55.  
  56.   pinMode(alarm_ActiveBuzzer_output_PIN_D2, OUTPUT);
  57.   pinMode(frontSensor_HC_SR04_Trigger_PIN_D3, OUTPUT);
  58.  
  59.   Serial.begin(9600);
  60. }
  61.  
  62. void loop(void)
  63. {
  64.   // Read distance using ultrasonic sensor
  65.   int distance = ultrasonic.read();
  66.  
  67.   Serial.print("Distance in CM: ");
  68.   Serial.println(distance);
  69.  
  70.   // Check if the distance is less than 20cm
  71.   if (distance < 20)
  72.   {
  73.     // Read heart rate using MAX30100 sensor
  74.     int heartRate = readHeartRate();
  75.     Serial.print("Heart Rate: ");
  76.     Serial.println(heartRate);
  77.  
  78.     // Check if heart rate is above 100 bpm
  79.     if (heartRate > 100)
  80.     {
  81.       Serial.println("HUMAN STRESSED");
  82.     }
  83.   }
  84.  
  85.   delay(1000);
  86. }
  87.  
  88. int readHeartRate()
  89. {
  90.   // TODO: Implement code to read heart rate using the MAX30100 sensor
  91.   // Return the heart rate value
  92.   return 0;
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement