/********* 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: "Arduino Temperature Control"
- Source Code compiled for: Arduino Uno
- Source Code created on: 2024-01-06 11:03:43
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Temperature control */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t Himanshu_PushButton_PIN_D2 = 2;
const uint8_t Himanshu_PushButton_PIN_D3 = 3;
const uint8_t Himanshu_PushButton_PIN_D4 = 4;
const uint8_t Himanshu_PushButton_PIN_D5 = 5;
const uint8_t Himanshu_DS18B20_DQ_PIN_D6 = 6;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
DS18B20 ds(Himanshu_DS18B20_DQ_PIN_D6); // Initialize DS18B20 object with D6 pin
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Temperature control */
const float temperatureThreshold = 25.0; // Temperature threshold for control
void setup(void)
{
// put your setup code here, to run once:
pinMode(Himanshu_PushButton_PIN_D2, INPUT_PULLUP);
pinMode(Himanshu_PushButton_PIN_D3, INPUT_PULLUP);
pinMode(Himanshu_PushButton_PIN_D4, INPUT_PULLUP);
pinMode(Himanshu_PushButton_PIN_D5, INPUT_PULLUP);
pinMode(Himanshu_DS18B20_DQ_PIN_D6, INPUT);
Serial.begin(9600);
}
void loop(void)
{
// put your main code here, to run repeatedly:
float temperature = ds.getTempC(); // Get the temperature reading
if (temperature >= temperatureThreshold) {
// Perform temperature control action
// Code to turn on cooling system or activate a fan
// code...
Serial.println("Temperature is above threshold. Turning on cooling system.");
}
else {
// Code to turn off cooling system or deactivate a fan
// code...
Serial.println("Temperature is below threshold. Turning off cooling system.");
}
delay(1000); // Delay for 1 second
}