//
//
#include "DHT.h"
#define DHTPIN 8
DHT dht(DHTPIN, DHT22);
#include <LiquidCrystal.h> // includes the LiquidCrystal Library
LiquidCrystal lcd(12, 11, 10, 6, 7, 2);
// Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
#include<Servo.h>
Servo motor1;
int poc_stanje =0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16,2);
dht.begin();
motor1.attach(9);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
//float h = dht.readHumidity(); //measure humidity
float t = dht.readTemperature(); //measure temperature
poc_stanje =0;
//int x=analogRead(A0);
int y=map(t,0,80,0,180);
//Serial.print("vrijednost izlaza potenciometra A0 je ");
Serial.println(t);
for(poc_stanje;poc_stanje<=y;poc_stanje++){
motor1.write(poc_stanje);
if(0<=poc_stanje&poc_stanje<=60){
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
//Serial.println(poc_stanje);
}
if(60<=poc_stanje&poc_stanje<=120){
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
if(120<=poc_stanje&poc_stanje<=180){
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
}
delay(200);
}
delay(2000);
lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Angle: "); // Prints "Arduino" on the LCD
lcd.print(y);
lcd.print(" degree");
//
lcd.setCursor(0,1);
lcd.print("Temp: "); // Prints "Arduino" on the LCD
lcd.print(t);
//
Serial.print("angle is ");
Serial.print(y);
Serial.println(" degree");
delay(5000);
}