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: "Temperature Display"
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-02-07 14:36:51
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Implementar un sistema de notificación que */
- /* enciende un LED si el sensor DHT22 detecta */
- /* temperatura sobre 28°C o humedad sobre 65%, */
- /* asegurando una supervisión constante del entorno. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <dht.h> //https://github.com/RobTillaart/DHTlib
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Configura los pines y objetos
- #define DHTPIN 2 // Digital pin connected to the DHT sensor
- #define DHTTYPE DHT11 // DHT 11
- #define LCD_ADDR 0x27 // Dirección I2C del LCD (puede variar)
- #define LED_PIN 13 // Pin connected to the LED
- DHT dht(DHTPIN, DHTTYPE);
- LiquidCrystal_I2C lcd(LCD_ADDR, 16, 2);
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(115200);
- // Inicializa el sensor DHT y el LCD
- dht.begin();
- lcd.init();
- lcd.backlight();
- // Configura el pin del LED como salida
- pinMode(LED_PIN, OUTPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Lee la temperatura y humedad
- float h = dht.readHumidity();
- float t = dht.readTemperature();
- // Muestra la información en el LCD
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.setCursor(10, 0);
- lcd.print("T:");
- lcd.print(t);
- lcd.print("C ");
- lcd.setCursor(10, 1);
- lcd.print("H:");
- lcd.print(h);
- lcd.print("%");
- // Verifica las condiciones de temperatura y humedad
- if (t > 28.0 || h > 65.0) {
- digitalWrite(LED_PIN, HIGH); // Enciende el LED
- } else {
- digitalWrite(LED_PIN, LOW); // Apaga el LED
- }
- delay(2000);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement