#include <Servo.h>
Servo myServo;
#include <LiquidCrystal.h>
int valV;
int angLL;
/* Display */
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#include "DHT.h"
#define DHTPIN 5
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
myServo.attach( 3);
myServo.write( 0);
lcd.begin(16, 2);
dht.begin();
pinMode(4, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//myServo.write( 0);
valV = analogRead(0); // reads the value of the potentiometer (value between 0 and 1023)
valV = map(valV, 0, 1023, 0, 100);
if (valV > 50) //значення потенціометра ppros
{
angLL = 0; // зазначений кут aangl
}
else
{
angLL = 180;
}
myServo.write( angLL);
float temp = dht.readTemperature();
float hum = dht.readHumidity();
if (temp<3) { // значення температури ttemp
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("prosVolt%=");
lcd.setCursor(11, 0);
lcd.print(valV);
lcd.setCursor(0, 1);
lcd.print("temp= ");
lcd.setCursor(6, 1);
lcd.print(temp);
Serial.print(F("prosVolt: "));
Serial.print(valV);
Serial.print(F("% Humidity: "));
Serial.print(hum);
Serial.print(F("% Temperature: "));
Serial.print(temp);
Serial.println(F("°C "));
delay(100);
//delay( 2000);
}