#define VERT_PIN A5
#define HORZ_PIN A4
#define SEL_PIN 2
const int kPinLed1=3; //sjever
const int kPinLed2=4; // istok
//const int kPinLed3=5;
const int kPinLed4=6; // zapad
#include <DHT.h>;
#define DHTPIN 7
// what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
float hum; //Stores humidity value
float tempC; //Stores temperature value
//float tempF;
float hum2; //Stores humidity value
float tempC2; //Stores temperature value
//float tempF2;
const int ledPinH = 8; // the number of the LED pin H
const int ledPinT = 9; // the number of the LED pin T
bool ispis = true;
int istok=1;
int zapad=1;
int sjever=1;
void setup() {
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
//pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
dht.begin();
Serial.begin(9600);
pinMode(ledPinH, OUTPUT);
pinMode(ledPinT, OUTPUT);
}
void loop() {
int vert = analogRead(VERT_PIN);
int horz = analogRead(HORZ_PIN);
bool selPressed = digitalRead(SEL_PIN) == LOW;
// horz goes from 0 (right) to 1023 (left)
// vert goes from 0 (bottom) to 1023 (top)
// selPressed is true is the joystick is pressed
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
tempC= dht.readTemperature();
if (vert<1023){
digitalWrite(kPinLed1, LOW);
}
else
{
digitalWrite(kPinLed1, HIGH);
if(sjever==1){
Serial.println("Nema podataka Temp & Humidity1");
sjever = 2;
istok=2;
zapad=2;
}
}
if ((vert<1)&&(hum2!=hum)||(tempC2!=tempC)){
//digitalWrite(kPinLed3, HIGH);
Serial.print("Humidity: ");
Serial.print(hum);
hum2=hum;
Serial.print(" %, Temp C: ");
Serial.print(tempC);
tempC2=tempC;
Serial.println(" Celsius");
//delay(2000);
sjever = 1;
istok=1;
zapad=1;
}
else
{
//digitalWrite(kPinLed3, LOW);
//Serial.print("Nema podataka Temp & Humidity");
}
if (horz<1023){
digitalWrite(kPinLed4, LOW);
}
else
{
digitalWrite(kPinLed4, HIGH);
if(zapad==1){
Serial.println("Nema podataka Temp & Humidity 4");
sjever = 2;
istok=2;
zapad=2;
}
}
if (horz<1){
digitalWrite(kPinLed2, HIGH);
if(istok==1){
Serial.println("Nema podataka Temp & Humidity2");
sjever = 2;
istok=2;
zapad=2;
}
}
else
{
digitalWrite(kPinLed2, LOW);
}
delay(2000);
/*Serial.print("Humidity2: ");
Serial.print(hum2);
//hum2=hum;
Serial.print(" %, Temp C: ");
Serial.print(tempC2);
//tempC2=tempC;
Serial.println(" Celsius");
*/
}
/*
#include <DHT.h>;
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//Constants
#define DHTPIN 7
// what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
float hum; //Stores humidity value
float tempC; //Stores temperature value
float tempF;
const int ledPinH = 8; // the number of the LED pin H
const int ledPinT = 9; // the number of the LED pin T
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16,2);
// Print a message to the LCD.
//lcd.setCursor(3, 0);
//lcd.print("hello, world!");
//
dht.begin();
Serial.begin(9600);
pinMode(ledPinH, OUTPUT);
pinMode(ledPinT, OUTPUT);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
// print the number of seconds since reset:
//lcd.print(millis() / 1000);
//lcd.print(" sekunde");
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
tempC= dht.readTemperature();
lcd.setCursor(0, 0);
lcd.print("Humidity: ");
lcd.setCursor(10, 0);
lcd.print(hum);
lcd.setCursor(0, 1);
lcd.print("Temp C: ");
lcd.setCursor(10, 1);
lcd.print(tempC);
if (hum>80) {
digitalWrite(ledPinH, HIGH);
//do stuff if the condition is true
}
else
{
digitalWrite(ledPinH, LOW);
//do stuff if the condition is not true
}
if (tempC>30) {
digitalWrite(ledPinT, HIGH);
//do stuff if the condition is true
}
else
{
digitalWrite(ledPinT, LOW);
//do stuff if the condition is not true
}
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp C: ");
Serial.print(tempC);
Serial.println(" Celsius");
delay(2000); //Delay 2 sec.
}
//................................
*/