Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: **Climate Control**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-12-06 17:43:04
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* The application must display real-time temperature */
- /* and humidity readings on a LiquidCrystal LCD, */
- /* leveraging the SimpleDHT library for sensor data */
- /* acquisition and ensuring accurate environmental */
- /* tracking. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <LiquidCrystal.h> // Library for controlling LCDs
- #include <SimpleDHT.h> // Library for DHT sensor
- #include <DHT.h> // Include DHT library
- #define DHTPIN 2 // Define DHT11 data pin
- #define DHTTYPE DHT11 // Define DHT11 sensor type
- DHT dht(DHTPIN, DHTTYPE); // Initialize DHT11 sensor
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize LCD pins
- int bulb1 = 6; // Define pin for first bulb
- int bulb2 = 7; // Define pin for second bulb
- int fan = 8; // Define pin for cooling fan
- void setup(void)
- {
- // Setup code to run once
- pinMode(bulb1, OUTPUT); // Set bulb1 pin as output
- pinMode(bulb2, OUTPUT); // Set bulb2 pin as output
- pinMode(fan, OUTPUT); // Set fan pin as output
- lcd.begin(16, 2); // Initialize LCD with 16 columns and 2 rows
- dht.begin(); // Initialize DHT11 sensor
- }
- void loop(void)
- {
- // Main code to run repeatedly
- float temp = dht.readTemperature(); // Read temperature from DHT11 sensor
- float humidity = dht.readHumidity(); // Read humidity from DHT11 sensor
- lcd.setCursor(0, 0); // Set cursor to first column, first row
- lcd.print("Temp: "); // Print "Temp: " on LCD
- lcd.print(temp); // Print temperature value on LCD
- lcd.print(" C"); // Print " C" on LCD
- lcd.setCursor(0, 1); // Set cursor to first column, second row
- lcd.print("Humidity: "); // Print "Humidity: " on LCD
- lcd.print(humidity); // Print humidity value on LCD
- lcd.print("%"); // Print "%" on LCD
- if (temp < 36) { // If temperature is below 36 degrees Celsius
- digitalWrite(bulb1, HIGH); // Turn on first bulb
- digitalWrite(bulb2, HIGH); // Turn on second bulb
- digitalWrite(fan, LOW); // Turn off cooling fan
- } else if (temp > 42) { // If temperature exceeds 42 degrees Celsius
- digitalWrite(bulb1, LOW); // Turn off first bulb
- digitalWrite(bulb2, LOW); // Turn off second bulb
- digitalWrite(fan, HIGH); // Turn on cooling fan
- }
- delay(1000); // Delay for 1 second
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement