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: "Heater Control" - Source Code compiled for: Arduino Uno - Source Code created on: 2024-04-20 14:25:37 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Measure temperature using DS18B20 sensor every */ /* 10s. Control heater based on temperature. Turn off */ /* heater if temperature > 37°C, turn on if <= 37°C. */ /* Display temperature on serial monitor. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
// Include the DS18B20 library /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); // Add the function prototype for updateOutputs() /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t Temp_sensor_DS18B20_DQ_PIN_D3 = 3; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t Heater_LED_PIN_D2 = 2; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool Heater_LED_PIN_D2_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float Heater_LED_PIN_D2_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ DS18B20 ds18b20(Temp_sensor_DS18B20_DQ_PIN_D3); // Create an instance of the DS18B20 library void setup(void) { // put your setup code here, to run once: pinMode(Temp_sensor_DS18B20_DQ_PIN_D3, INPUT); pinMode(Heater_LED_PIN_D2, OUTPUT); Serial.begin(9600); // Initialize serial communication } void loop(void) { // put your main code here, to run repeatedly: float temperature = ds18b20.getTempC(); // Get temperature from DS18B20 sensor // Control heater based on temperature if (temperature > 37) { Heater_LED_PIN_D2_rawData = 0; // Turn off heater } else { Heater_LED_PIN_D2_rawData = 1; // Turn on heater } // Display temperature on serial monitor Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" C"); updateOutputs(); // Refresh output data delay(10000); // Wait for 10 seconds } void updateOutputs() { digitalWrite(Heater_LED_PIN_D2, Heater_LED_PIN_D2_rawData); }
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)