Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. // W gruncie rzeczy to zostało tylko aby program się wyłączał gdy temperatura osiągnie wartość 100
  2.  
  3. #include <DHT.h>
  4.  
  5. #define DHT11_PIN A0
  6. DHT dht;
  7.  
  8. String a;
  9. int temperatura;
  10.  
  11.  
  12. void setup()
  13. {
  14.  
  15.  Serial.begin(9600);
  16.  pinMode(7, OUTPUT);
  17.  dht.setup(DHT11_PIN);
  18. }
  19. ////////////////////////////////////////////////////////////////////////////
  20.  
  21. void loop()
  22. {
  23.   //Pobranie informacji o temperaturze
  24.   int temperatura = dht.getTemperature();
  25.   Serial.print(temperatura);
  26.   Serial.println("*C");
  27.  
  28.   while (temperatura<=24)
  29.   {
  30.      Serial.println(" W WHILE");
  31.      int temperatura = dht.getTemperature();
  32.      Serial.print(temperatura);
  33.  
  34.  
  35.  
  36.  
  37.   while (Serial.available())
  38.   {
  39.     a=Serial.readString();
  40.     Serial.println(a);
  41.  
  42.    
  43.     if (a=="ON")
  44.     {
  45.       digitalWrite(7,HIGH);
  46.       Serial.println("WŁĄCZONO OGRZEWANIE");
  47.     }
  48.  
  49.     if (a=="OFF")
  50.     {
  51.       digitalWrite(7,LOW);
  52.       Serial.println("OGRZEWANIE WYŁĄCZONO");
  53.     }
  54.  
  55.    
  56.     }
  57.     delay(1000);
  58.   }
  59.  
  60.  
  61.  
  62.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement