Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DHT.h"
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(2,3,4,5,6,7);
- #define DHTPIN 8
- #define DHTTYPE DHT11
- DHT dht(DHTPIN, DHTTYPE);
- int odczytanaWartosc = 0;
- float PWM = 0;
- int PWML = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(9, OUTPUT);
- dht.begin();
- lcd.begin(16,2);
- }
- void loop() {
- delay(500);
- float h = dht.readHumidity();
- float t = dht.readTemperature();
- // Read temperature as Fahrenheit (isFahrenheit = true)
- float f = dht.readTemperature(true);
- // Check if any reads failed and exit early (to try again).
- if (isnan(h) || isnan(t) || isnan(f)) {
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- float hic = dht.computeHeatIndex(t, h, false);
- Serial.print("Humidity: ");
- Serial.print(h);
- Serial.print(" %\t");
- Serial.print("Temperature: ");
- Serial.print(t);
- Serial.print(" *C ");
- Serial.print("Heat index: ");
- Serial.print(hic);
- Serial.print(" *C ");
- Serial.print("\n");
- lcd.setCursor(0,0);
- lcd.print("Temp: ");
- lcd.print(t);
- lcd.print("'C");
- lcd.setCursor(0,1);
- lcd.print("Humidity: ");
- lcd.print(h);
- lcd.print("%");
- odczytanaWartosc = analogRead(A5);//Odczytujemy wartość napięcia
- PWM = odczytanaWartosc * (255.0/1023.0); //Przeliczenie wartości na napięcie
- PWML = PWM/25;
- analogWrite(9,(1,2*PWM));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement