SHARE
TWEET

Untitled

Pheasant Jun 5th, 2020 984 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3. #include <dht.h>
  4.  
  5. LiquidCrystal_I2C lcd(0x27, 27 , 28);  // Ustawienie adresu ukladu na 0x27
  6. dht DHT;
  7. #define DHT11_PIN 7
  8.  
  9. const byte interruptPinINC = 2;
  10. const byte interruptPinDEC = 3;
  11.  
  12. void setup()
  13. {
  14.   pinMode(8, OUTPUT);
  15.   lcd.init();
  16.   lcd.begin(16, 2);
  17.   lcd.backlight(); // zalaczenie podwietlenia
  18.   lcd.setCursor(0, 0);
  19.   digitalWrite(8, LOW);
  20.   pinMode(interruptPinINC, INPUT_PULLUP);
  21.   attachInterrupt(digitalPinToInterrupt(interruptPinINC), increase, FALLING);
  22.   pinMode(interruptPinDEC, INPUT_PULLUP);
  23.   attachInterrupt(digitalPinToInterrupt(interruptPinDEC), decrease, FALLING);
  24. }
  25.  
  26. volatile double given = 50;
  27.  
  28. void loop(){
  29.   lcd.setCursor(0, 0);
  30.   int chk = DHT.read11(DHT11_PIN);
  31.   lcd.print("temp. ");
  32.   lcd.print(DHT.temperature);
  33.   lcd.print((char)223);
  34.   lcd.print("C");
  35.   lcd.setCursor(0, 1);
  36.   lcd.print("zada. ");
  37.   lcd.print(given);
  38.   lcd.print((char)223);
  39.   lcd.print("C");
  40.   if (DHT.temperature >= given) {
  41.     digitalWrite(8, LOW);
  42.   } else {
  43.     digitalWrite(8, HIGH);
  44.   }
  45.   delay(600);
  46. }
  47. void increase(){
  48.   given++ ;
  49. }
  50. void decrease(){
  51.   given-- ;
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top