Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <dht11.h>
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #define BACKLIGHT_PIN 3
- LiquidCrystal_I2C lcd(0x3F, 2,1,0,4,5,6,7);
- dht11 DHT11;
- #define DHT11PIN 8 //przypisanie pinu 2 Arduino jako odczyt z sensora
- void setup()
- {
- Serial.begin(115200);
- Serial.println("Program testowy DHT11");
- Serial.println();
- lcd.begin(20,4);
- lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
- lcd.setBacklight(HIGH);
- }
- void loop()
- {
- int chk = DHT11.read(DHT11PIN);
- lcd.home();
- lcd.print("Stan sensora: ");
- switch (chk)
- {
- case DHTLIB_OK:
- lcd.print("OK");
- break;
- }
- lcd.setCursor(0,1);
- lcd.print("Wilg (%): ");
- lcd.print((float)DHT11.humidity, 0);
- lcd.setCursor(0,2);
- lcd.print("Temp (C): ");
- lcd.println((float)DHT11.temperature, 0);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement