//Ejercicio 1
//Orlanxavier Iglesias
#include <DHT.h>
#include <LiquidCrystal.h>
#define DHTPIN 7
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int led = 8;
const int buzzer = 12;
void setup() {
// put your setup code here, to run once:
dht.begin();
lcd.begin(16, 2);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
float temperatura = dht.readTemperature();
float humedad = dht.readHumidity();
delay(3000);
//primera fila
if(temperatura > 30)
{
lcd.scrollDisplayLeft();
lcd.setCursor(0, 0);
lcd.print("Temperatura Alta - ");
lcd.print(temperatura);
lcd.print(" C");
digitalWrite(led, HIGH);
}
else
{
lcd.setCursor(0, 0);
digitalWrite(led, LOW);
lcd.print("");
}
//segunda fila
if(humedad < 40)
{
lcd.scrollDisplayLeft();
lcd.setCursor(0, 1);
lcd.print("Humedad Baja Revisar - ");
lcd.print(humedad);
lcd.print("%");
tone(buzzer, 100);
}
else
{
lcd.setCursor(0, 1);
noTone(buzzer);
lcd.print("");
}
}