CCCPaste

"Heat Control" rev_01

/********* 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: "Heat Control"
	- Source Code compiled for: ESP32 DevKit V1
	- Source Code created on: 2024-02-11 10:35:13

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* turn on when set temperature reached */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 	//https://github.com/matmunk/DS18B20

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t heat_DS18B20_DQ_PIN_D4 = 4;
const uint8_t HEAT_PIN = 5; // Replace with the actual pin number for the heat pin

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
DS18B20 ds(heat_DS18B20_DQ_PIN_D4);

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* turn on when set temperature reached */
bool isTemperatureReached(float setTemperature, float currentTemperature)
{
	return currentTemperature >= setTemperature;
}
/****** END SYSTEM REQUIREMENTS *****/

void setup(void)
{
	// put your setup code here, to run once:
	pinMode(heat_DS18B20_DQ_PIN_D4, INPUT);
	pinMode(HEAT_PIN, OUTPUT); // Set the heat pin as output

}

void loop(void)
{
	// put your main code here, to run repeatedly:
	float setTemperature = 25.0; // Set temperature in degrees Celsius

	// Read current temperature
	float currentTemperature = ds.getTempC();

	// Check if set temperature is reached
	if (isTemperatureReached(setTemperature, currentTemperature))
	{
		// Add code here to turn on the desired device or trigger an action
		// For example, you can use digitalWrite() to turn on a pin connected to a device
		digitalWrite(HEAT_PIN, HIGH);
	}

	delay(1000); // Delay for 1 second before checking the temperature again
}