#include <Arduino.h>
#include <LiquidCrystal.h>
#include <DHT.h>
boolean estadoLed = false;
unsigned long intervaloEncendido = 60000;
unsigned long IntervaloApagado = 10000;
unsigned long tiempoAnteriorEncendido;
unsigned long tiempoAnteriorApagado;
unsigned long tiempoPresento;
enum {ENCENDIDO, APAGADO};
int SENSOR = 8;
int VO = 0;
int RS = 2;
int E = 3;
int D4 = 4;
int D5 = 5;
int D6 = 6;
int D7 = 7;
int temp;
int humedad;
DHT dht (SENSOR, DHT11);
LiquidCrystal lcd (RS, E, D4, D5 ,D6, D7);
void setup(){
pinMode(13,OUTPUT);
digitalWrite(13,estadoLed);
}
void loop(){
switch(estadoLed) {
case APAGADO: if ((millis()-tiempoAnteriorEncendido >= intervaloEncendido)){
estadoLed = ENCENDIDO;
digitalWrite(13, estadoLed);
tiempoAnteriorApagado = millis();
}
break;
case ENCENDIDO: if (millis()-tiempoAnteriorApagado >= IntervaloApagado){
estadoLed = APAGADO;
digitalWrite(13, estadoLed);
tiempoAnteriorEncendido = millis();
}
break;
}
if (millis()-tiempoPresento > 500UL) {
humedad = dht.readHumidity();
temp = dht.readTemperature();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temperatura: ");
lcd.print(temp);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Humedad: ");
lcd.print(humedad);
lcd.print("%");
tiempoPresento = millis(); // <=== faltaba esto.
//delay(500);
}
}