Advertisement
pleasedontcode

"Arduino Temperature Control" rev_02

Jan 6th, 2024
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: "Arduino Temperature Control"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-06 11:03:43
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Temperature control */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <DS18B20.h>
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  32. const uint8_t Himanshu_PushButton_PIN_D2 = 2;
  33. const uint8_t Himanshu_PushButton_PIN_D3 = 3;
  34. const uint8_t Himanshu_PushButton_PIN_D4 = 4;
  35. const uint8_t Himanshu_PushButton_PIN_D5 = 5;
  36. const uint8_t Himanshu_DS18B20_DQ_PIN_D6 = 6;
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39. DS18B20 ds(Himanshu_DS18B20_DQ_PIN_D6); // Initialize DS18B20 object with D6 pin
  40.  
  41. /****** SYSTEM REQUIREMENTS *****/
  42. /****** SYSTEM REQUIREMENT 1 *****/
  43. /* Temperature control */
  44. const float temperatureThreshold = 25.0; // Temperature threshold for control
  45.  
  46. void setup(void)
  47. {
  48.   // put your setup code here, to run once:
  49.  
  50.   pinMode(Himanshu_PushButton_PIN_D2, INPUT_PULLUP);
  51.   pinMode(Himanshu_PushButton_PIN_D3, INPUT_PULLUP);
  52.   pinMode(Himanshu_PushButton_PIN_D4, INPUT_PULLUP);
  53.   pinMode(Himanshu_PushButton_PIN_D5, INPUT_PULLUP);
  54.   pinMode(Himanshu_DS18B20_DQ_PIN_D6, INPUT);
  55.  
  56.   Serial.begin(9600);
  57. }
  58.  
  59. void loop(void)
  60. {
  61.   // put your main code here, to run repeatedly:
  62.  
  63.   float temperature = ds.getTempC(); // Get the temperature reading
  64.  
  65.   if (temperature >= temperatureThreshold) {
  66.     // Perform temperature control action
  67.     // Code to turn on cooling system or activate a fan
  68.     // code...
  69.     Serial.println("Temperature is above threshold. Turning on cooling system.");
  70.   }
  71.   else {
  72.     // Code to turn off cooling system or deactivate a fan
  73.     // code...
  74.     Serial.println("Temperature is below threshold. Turning off cooling system.");
  75.   }
  76.  
  77.   delay(1000); // Delay for 1 second
  78. }
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement