Advertisement
pleasedontcode

**Climate Control** rev_01

Dec 6th, 2024
68
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: **Climate Control**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-06 17:43:04
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The application must display real-time temperature */
  21.     /* and humidity readings on a LiquidCrystal LCD, */
  22.     /* leveraging the SimpleDHT library for sensor data */
  23.     /* acquisition and ensuring accurate environmental */
  24.     /* tracking. */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /* START CODE */
  28.  
  29. /****** DEFINITION OF LIBRARIES *****/
  30. #include <LiquidCrystal.h>  // Library for controlling LCDs
  31. #include <SimpleDHT.h>  // Library for DHT sensor
  32. #include <DHT.h> // Include DHT library
  33.  
  34. #define DHTPIN 2 // Define DHT11 data pin
  35. #define DHTTYPE DHT11 // Define DHT11 sensor type
  36.  
  37. DHT dht(DHTPIN, DHTTYPE); // Initialize DHT11 sensor
  38.  
  39. LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize LCD pins
  40.  
  41. int bulb1 = 6; // Define pin for first bulb
  42. int bulb2 = 7; // Define pin for second bulb
  43. int fan = 8; // Define pin for cooling fan
  44.  
  45. void setup(void)
  46. {
  47.     // Setup code to run once
  48.     pinMode(bulb1, OUTPUT); // Set bulb1 pin as output
  49.     pinMode(bulb2, OUTPUT); // Set bulb2 pin as output
  50.     pinMode(fan, OUTPUT); // Set fan pin as output
  51.    
  52.     lcd.begin(16, 2); // Initialize LCD with 16 columns and 2 rows
  53.     dht.begin(); // Initialize DHT11 sensor
  54. }
  55.  
  56. void loop(void)
  57. {
  58.     // Main code to run repeatedly
  59.     float temp = dht.readTemperature(); // Read temperature from DHT11 sensor
  60.     float humidity = dht.readHumidity(); // Read humidity from DHT11 sensor
  61.    
  62.     lcd.setCursor(0, 0); // Set cursor to first column, first row
  63.     lcd.print("Temp: "); // Print "Temp: " on LCD
  64.     lcd.print(temp); // Print temperature value on LCD
  65.     lcd.print(" C"); // Print " C" on LCD
  66.    
  67.     lcd.setCursor(0, 1); // Set cursor to first column, second row
  68.     lcd.print("Humidity: "); // Print "Humidity: " on LCD
  69.     lcd.print(humidity); // Print humidity value on LCD
  70.     lcd.print("%"); // Print "%" on LCD
  71.    
  72.     if (temp < 36) { // If temperature is below 36 degrees Celsius
  73.         digitalWrite(bulb1, HIGH); // Turn on first bulb
  74.         digitalWrite(bulb2, HIGH); // Turn on second bulb
  75.         digitalWrite(fan, LOW); // Turn off cooling fan
  76.     } else if (temp > 42) { // If temperature exceeds 42 degrees Celsius
  77.         digitalWrite(bulb1, LOW); // Turn off first bulb
  78.         digitalWrite(bulb2, LOW); // Turn off second bulb
  79.         digitalWrite(fan, HIGH); // Turn on cooling fan
  80.     }
  81.    
  82.     delay(1000); // Delay for 1 second
  83. }
  84.  
  85. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement