Advertisement
pleasedontcode

Stress Detection rev_28

Jan 18th, 2024
91
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: Stress Detection
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-18 23:25:28
  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 <Wire.h>
  27. #include <Ultrasonic.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void updateOutputs(void);
  33. unsigned int readHeartRate(void);
  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 LIBRARIES CLASS INSTANCES *****/
  44. Ultrasonic ultrasonic(frontSensor_HC_SR04_Trigger_PIN_D3, frontSensor_HC_SR04_Echo_PIN_D4);
  45.  
  46. void setup()
  47. {
  48.   // Initialize digital inputs
  49.   pinMode(sensor_MAX30100_INT_PIN_D5, INPUT_PULLUP);
  50.  
  51.   // Initialize digital outputs
  52.   pinMode(alarm_ActiveBuzzer_output_PIN_D2, OUTPUT);
  53.   pinMode(frontSensor_HC_SR04_Trigger_PIN_D3, OUTPUT);
  54.  
  55.   Serial.begin(9600);
  56. }
  57.  
  58. void loop()
  59. {
  60.   // Read distance using ultrasonic sensor
  61.   unsigned int distance = ultrasonic.read();
  62.  
  63.   // Read heart rate from sensor
  64.   unsigned int heartRate = readHeartRate();
  65.  
  66.   // Check if the distance is less than 20cm and heart rate is above 100 bpm
  67.   if (distance < 20 && heartRate > 100)
  68.   {
  69.     Serial.println("HUMAN STRESSED");
  70.   }
  71.  
  72.   delay(1000);
  73. }
  74.  
  75. unsigned int readHeartRate()
  76. {
  77.   // Implement code here to read the heart rate from the sensor
  78. }
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement