Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* 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: **Data Monitor** - Source Code NOT compiled for: Arduino Nano ESP32 - Source Code created on: 2024-10-07 23:19:15 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Read temperature from DS18B20 sensor and display */ /* on LCD screen. */ /****** SYSTEM REQUIREMENT 2 *****/ /* Perform a countdown of 10 seconds after each */ /* temperature reading using LiquidCrystal library */ /* for display control. */ /****** SYSTEM REQUIREMENT 3 *****/ /* use max pulse oximeter */ /****** SYSTEM REQUIREMENT 4 *****/ /* use non blocking code. */ /****** END SYSTEM REQUIREMENTS *****/ /* START CODE */ /****** DEFINITION OF LIBRARIES *****/ #include
#include
// https://github.com/matmunk/DS18B20 #include
// https://github.com/arduino-libraries/LiquidCrystal #include
// https://github.com/adafruit/DHT-sensor-library #include
// https://github.com/gabriel-milan/Arduino-MAX30100 /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(); void readTemperature(); void displayCountdown(int seconds); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t temperatureSensor_DHT22_DOUT_PIN_D9 = 9; const uint8_t PulseOximeter_MAX30100_INT_PIN_D2 = 2; const uint8_t temperatureSensor_DS18B20_DQ_PIN_D4 = 4; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t myLCD_LCD1602_RS_PIN_D3 = 3; const uint8_t myLCD_LCD1602_D4_PIN_D5 = 5; const uint8_t myLCD_LCD1602_D5_PIN_D6 = 6; const uint8_t myLCD_LCD1602_D6_PIN_D7 = 7; const uint8_t myLCD_LCD1602_D7_PIN_D8 = 8; /***** DEFINITION OF OUTPUT VARIABLES *****/ LiquidCrystal lcd(myLCD_LCD1602_RS_PIN_D3, myLCD_LCD1602_D4_PIN_D5, myLCD_LCD1602_D5_PIN_D6, myLCD_LCD1602_D6_PIN_D7, myLCD_LCD1602_D7_PIN_D8); PulseOximeter pox; DS18B20 ds18b20(temperatureSensor_DS18B20_DQ_PIN_D4); // Initialize DS18B20 with the data pin // Non-blocking timing variables unsigned long previousMillis = 0; const long interval = 1000; // Interval for reading temperature and updating display bool countdownActive = false; int countdownSeconds = 10; void setup(void) { // Initialize Serial for debugging Serial.begin(115200); // Initialize LCD lcd.begin(16, 2); lcd.clear(); // Initialize Pulse Oximeter if (!pox.begin()) { Serial.println("Failed to initialize pulse oximeter"); while (1); } // Set up the DS18B20 sensor ds18b20.Update(); // Start temperature conversion } void loop(void) { unsigned long currentMillis = millis(); // Check if it's time to read temperature and update display if (currentMillis - previousMillis >= interval) { previousMillis = currentMillis; // Read temperature and display it readTemperature(); // Start countdown countdownActive = true; countdownSeconds = 10; // Reset countdown } // Perform countdown if active if (countdownActive) { displayCountdown(countdownSeconds); countdownSeconds--; if (countdownSeconds < 0) { countdownActive = false; // Stop countdown when done } } // Update pulse oximeter readings pox.update(); // Display heart rate and SpO2 Serial.print("Heart rate: "); Serial.print(pox.getHeartRate()); Serial.print(" bpm / SpO2: "); Serial.print(pox.getSpO2()); Serial.println(" %"); } void readTemperature() { float temperature = ds18b20.GetTemperature
(); lcd.setCursor(0, 0); lcd.print("Temp: "); lcd.print(temperature); lcd.print(" C"); } void displayCountdown(int seconds) { lcd.setCursor(0, 1); lcd.print("Countdown: "); lcd.print(seconds); } /* END CODE */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)