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: Temperature Control - Source Code compiled for: Arduino Uno - Source Code created on: 2024-04-20 09:07:46 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Use a DS18B20 sensor to measure temperature and */ /* display it every 10 seconds and use a heater. If */ /* the temperature is >= 37 turn off the heater and */ /* if it’s < 37 turn on the heater. */ /****** END SYSTEM REQUIREMENTS *****/ /********* User code review feedback ********** #### Feedback 1 #### - please use a different library ********* User code review feedback **********/ /****** DEFINITION OF LIBRARIES *****/ #include
#include
/****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t Temp_sensor_DS18B20_DQ_PIN_D2 = 2; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t Heater_LED_PIN_D3 = 3; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool Heater_LED_PIN_D3_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float Heater_LED_PIN_D3_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ OneWire oneWire(Temp_sensor_DS18B20_DQ_PIN_D2); DallasTemperature ds18b20(&oneWire); void setup(void) { // put your setup code here, to run once: Serial.begin(9600); ds18b20.begin(); uint8_t address[] = {0x28, 0xFF, 0x28, 0x9C, 0x71, 0x17, 0x03, 0x8E}; // Replace with your DS18B20 sensor address ds18b20.setLowAlarmTemp(address, 37); // Set low alarm temperature to 37 degrees ds18b20.setHighAlarmTemp(address, 37); // Set high alarm temperature to 37 degrees ds18b20.setResolution(address, 12); // Set the resolution of the sensor pinMode(Heater_LED_PIN_D3, OUTPUT); } void loop(void) { // put your main code here, to run repeatedly: ds18b20.requestTemperatures(); // Read temperature values float temperature = ds18b20.getTempCByIndex(0); // Get temperature in Celsius Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" C"); if (temperature >= 37) { // Turn off the heater Heater_LED_PIN_D3_rawData = 0; updateOutputs(); } else { // Turn on the heater Heater_LED_PIN_D3_rawData = 1; updateOutputs(); } delay(10000); } void updateOutputs() { digitalWrite(Heater_LED_PIN_D3, Heater_LED_PIN_D3_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)