mpmcws

LCD + DHT22

Jul 16th, 2018
42
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //LCD (no I2C) con DHT22
  2. //Tolentino Codesta - Cerani luglio 2018
  3. #include <LiquidCrystal.h> // libreria
  4. #include <DHT.h>
  5. #include <Adafruit_Sensor.h>
  6. #define DHTTYPE DHT22
  7. #define DHTPIN 9
  8. DHT dht(DHTPIN, DHTTYPE);
  9. float celsius;
  10. float humidity;
  11. const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  12. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  13. void setup() {
  14.   dht.begin();
  15.   lcd.begin(16, 2);
  16. }
  17. void loop() {
  18.  humidity = dht.readHumidity();
  19.   celsius = dht.readTemperature();
  20.   lcd.setCursor(0,0);
  21.    lcd.print((char)223);
  22.   lcd.print("C ");
  23.   lcd.print(celsius);
  24.   lcd.setCursor(0,1);
  25.    lcd.print("UR ");
  26.   lcd.print (humidity);
  27.   delay (2000);
  28. }
RAW Paste Data