#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
LiquidCrystal_I2C lcd_verde(0x27, 16, 2);
DHT dht_blanco(3, DHT22);
void setup() {
// put your setup code here, to run once:
pinMode(2, INPUT_PULLUP);
lcd_verde.init();
lcd_verde.backlight();
dht_blanco.begin();
pantallazo();
}
void pantallazo(){
lcd_verde.setCursor(0,0);
lcd_verde.print(" Hola mundo UNI");
lcd_verde.setCursor(0,1);
lcd_verde.print("Maestria IA 2026");
delay(3000);
lcd_verde.clear();
lcd_verde.setCursor(0,0);
lcd_verde.print("Sist. Embebidos");
lcd_verde.setCursor(0,1);
lcd_verde.print("Display LCD 2x16");
delay(3000);
lcd_verde.clear();
}
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(2) == LOW){
lcd_verde.setCursor(11,0);
lcd_verde.print("B:ON ");
}
else{
lcd_verde.setCursor(11,0);
lcd_verde.print("B:OFF");
}
int analogValue = analogRead(A0);
//siguiente va el escalamiento de la medida
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
lcd_verde.setCursor(0,0);
lcd_verde.print("S1:");
lcd_verde.print(celsius);
lcd_verde.write(0xDF);
lcd_verde.print("C ");
float h = dht_blanco.readHumidity();
float t = dht_blanco.readTemperature();
lcd_verde.setCursor(0,1);
lcd_verde.print("S2:");
lcd_verde.print(t);
lcd_verde.write(0xDF);
lcd_verde.print("C ");
lcd_verde.print(h);
}