Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include "DHT.h"
  2. #include <LiquidCrystal.h>
  3.  
  4. LiquidCrystal lcd(2,3,4,5,6,7);
  5.  
  6. #define DHTPIN 8
  7. #define DHTTYPE DHT11
  8.  
  9. DHT dht(DHTPIN, DHTTYPE);
  10.  
  11. int odczytanaWartosc = 0;
  12. float PWM = 0;
  13. int PWML = 0;
  14.  
  15. void setup() {
  16. Serial.begin(9600);
  17. pinMode(9, OUTPUT);
  18. dht.begin();
  19. lcd.begin(16,2);
  20. }
  21.  
  22. void loop() {
  23. delay(500);
  24. float h = dht.readHumidity();
  25. float t = dht.readTemperature();
  26. // Read temperature as Fahrenheit (isFahrenheit = true)
  27. float f = dht.readTemperature(true);
  28. // Check if any reads failed and exit early (to try again).
  29. if (isnan(h) || isnan(t) || isnan(f)) {
  30. Serial.println("Failed to read from DHT sensor!");
  31. return;
  32. }
  33. float hic = dht.computeHeatIndex(t, h, false);
  34.  
  35. Serial.print("Humidity: ");
  36. Serial.print(h);
  37. Serial.print(" %\t");
  38. Serial.print("Temperature: ");
  39. Serial.print(t);
  40. Serial.print(" *C ");
  41. Serial.print("Heat index: ");
  42. Serial.print(hic);
  43. Serial.print(" *C ");
  44. Serial.print("\n");
  45. lcd.setCursor(0,0);
  46. lcd.print("Temp: ");
  47. lcd.print(t);
  48. lcd.print("'C");
  49. lcd.setCursor(0,1);
  50. lcd.print("Humidity: ");
  51. lcd.print(h);
  52. lcd.print("%");
  53. odczytanaWartosc = analogRead(A5);//Odczytujemy wartość napięcia
  54. PWM = odczytanaWartosc * (255.0/1023.0); //Przeliczenie wartości na napięcie
  55. PWML = PWM/25;
  56. analogWrite(9,(1,2*PWM));
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement