/********* 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 Controller - Source Code compiled for: Arduino Uno - Source Code created on: 2024-04-20 08:15:27 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Develop an Arduino code using DS18B20 sensor to */ /* measure temperature every 10s. Display temperature */ /* on serial monitor. Implement a heater. If */ /* temperature is >= 37°C, turn off the heater. If */ /* temperature is < 37°C, turn on the heater. */ /****** SYSTEM REQUIREMENT 2 *****/ /* Develop an Arduino code using DS18B20 sensor to */ /* measure temperature every 10s. Display temperature */ /* on serial monitor. Implement a heater. If */ /* temperature is >= 37°C, turn off the heater. If */ /* temperature is < 37°C, turn on the heater. */ /****** END SYSTEM REQUIREMENTS *****/ /********* User code review feedback ********** #### Feedback 1 #### - try use a different library ********* User code review feedback **********/ /****** DEFINITION OF LIBRARIES *****/ #include #include /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Develop an Arduino code using DS18B20 sensor to */ /* measure temperature every 10s. Display temperature */ /* on serial monitor. Implement a heater. If */ /* temperature is >= 37°C, turn off the heater. If */ /* temperature is < 37°C, turn on the heater. */ /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t Temp_sensor_DS18B20_DQ_PIN = 2; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t Heater_LED_PIN = 3; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool Heater_LED_PIN_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float Heater_LED_PIN_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ OneWire oneWire(Temp_sensor_DS18B20_DQ_PIN); DallasTemperature sensors(&oneWire); void setup(void) { // put your setup code here, to run once: sensors.begin(); pinMode(Heater_LED_PIN, OUTPUT); Serial.begin(9600); } void loop(void) { // put your main code here, to run repeatedly: sensors.requestTemperatures(); // Read temperature from DS18B20 sensor float temperature = sensors.getTempCByIndex(0); // Display temperature on serial monitor Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" °C"); // Control the heater based on temperature if (temperature >= 37.0) { Heater_LED_PIN_rawData = 0; // Turn off the heater } else { Heater_LED_PIN_rawData = 1; // Turn on the heater } updateOutputs(); // Refresh output data delay(10000); // Wait for 10 seconds } void updateOutputs() { digitalWrite(Heater_LED_PIN, Heater_LED_PIN_rawData); }