Advertisement
placek

Untitled

Jan 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <dht11.h>
  2. #include <Wire.h>
  3. #include <LiquidCrystal_I2C.h>
  4.  
  5. #define BACKLIGHT_PIN 3
  6. LiquidCrystal_I2C lcd(0x3F, 2,1,0,4,5,6,7);
  7.  
  8. dht11 DHT11;
  9. #define DHT11PIN 8 //przypisanie pinu 2 Arduino jako odczyt z sensora
  10.  
  11.  
  12.  
  13. void setup()
  14. {
  15. Serial.begin(115200);
  16. Serial.println("Program testowy DHT11");
  17. Serial.println();
  18.  
  19. lcd.begin(20,4);
  20. lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  21. lcd.setBacklight(HIGH);
  22.  
  23.  
  24. }
  25.  
  26. void loop()
  27. {
  28. int chk = DHT11.read(DHT11PIN);
  29. lcd.home();
  30. lcd.print("Stan sensora: ");
  31. switch (chk)
  32. {
  33. case DHTLIB_OK:
  34. lcd.print("OK");
  35. break;
  36.  
  37. }
  38. lcd.setCursor(0,1);
  39. lcd.print("Wilg (%): ");
  40. lcd.print((float)DHT11.humidity, 0);
  41.  
  42. lcd.setCursor(0,2);
  43. lcd.print("Temp (C): ");
  44. lcd.println((float)DHT11.temperature, 0);
  45.  
  46. delay(1000);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement