patriotaSJ

DHT11 con LCD16x2

Jun 12th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include "DHT.h"
  2. #include <LiquidCrystal.h>
  3. #define DHTPIN 4
  4. #define DHTTYPE DHT11
  5. DHT dht(DHTPIN, DHTTYPE);
  6.  // Initialize the library with the interface pins
  7. LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
  8.  
  9. void setup() {
  10. Serial.begin(9600);
  11. lcd.begin(16, 2);
  12. dht.begin();
  13. //lcd.print("BIENVENIDOS");
  14. }
  15. void loop() {  
  16. int h = dht.readHumidity();// Lee la humedad
  17. int t= dht.readTemperature();//Lee la temperatura
  18. //////////////////////////////////////////////////Humedad
  19. lcd.setCursor(0,0);   //columna 0, fila 0
  20. lcd.print("Humedad:  %");   //8 caracteres
  21. lcd.setCursor(8,0);
  22. lcd.print(h);         //Escribe la humedad
  23. //Serial.println(" %");                    
  24. ///////////////////////////////////////////////////Temperatura              
  25. lcd.setCursor(0,1);
  26. lcd.print("Temperatura:   C");                  
  27. lcd.setCursor(12,1);
  28. lcd.print(t);//Escribe la temperatura
  29. //Serial.println(" C'");                  
  30. //delay (150);
  31. ///////////////////////////////////////////////////            
  32. }
Advertisement
Add Comment
Please, Sign In to add comment