38 lines
1006 B
Arduino
38 lines
1006 B
Arduino
|
// include the library code:
|
||
|
#include <LiquidCrystal.h>
|
||
|
|
||
|
// initialize the library with the numbers of the interface pins
|
||
|
LiquidCrystal lcd(12, 11, 9, 8, 7, 6);
|
||
|
byte sensorHum = A7; // Analog pin 7
|
||
|
int humedad1;
|
||
|
|
||
|
void setup() {
|
||
|
Serial.begin(9600);
|
||
|
lcd.begin(16, 2);
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
//humedad1 = analogRead(sensorHum);
|
||
|
humedad1 = map(analogRead(sensorHum), 0 , 1023, 0, 100);
|
||
|
String humedad = (String)humedad1;
|
||
|
Serial.println("Humedad : " + humedad + "%");
|
||
|
if(humedad1 < 30) {
|
||
|
lcd.setCursor(0, 0);
|
||
|
lcd.print("Humedad : " + humedad + "%");
|
||
|
lcd.setCursor(0, 1);
|
||
|
lcd.print("Tengo sed =( !!!");
|
||
|
} else if(humedad1 > 60) {
|
||
|
lcd.setCursor(0, 0);
|
||
|
lcd.print("Humedad : " + humedad + "%");
|
||
|
lcd.setCursor(0, 1);
|
||
|
lcd.print(" Me ahogo!!! =(");
|
||
|
} else {
|
||
|
lcd.setCursor(0, 0);
|
||
|
lcd.print("Humedad : " + humedad + "%");
|
||
|
lcd.setCursor(0, 1);
|
||
|
lcd.print(" Esto es vida =)");
|
||
|
}
|
||
|
delay(5000);
|
||
|
lcd.clear();
|
||
|
}
|