// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

// REQUIRES the following Arduino libraries:
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor

#include "DHT.h"
const int sakumalaiks=millis();
#define DHTPIN 2   
#define DHTTYPE DHT22   
DHT dht(DHTPIN, DHTTYPE);
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  dht.begin();
  int time = 4;
  int t = millis();
  while (millis()<=3000){

    if (millis()-t >= 1000){
      // Serial.println((millis()/1000)+1);
      Serial.println(--time);
      t = millis();
    }
  }
}
void loop() {
if ( Serial.available() > 0 ) {
    char simbols = Serial.read();
    if (simbols != 13 && simbols != 10){
      if (simbols=='T'){
        Serial.print(simbols);
        Serial.println(" - sanemts, LED ON");
      }else if(simbols=='H'){
        Serial.print(simbols);
        Serial.println(" - sanemts, LED ON");
      }else{
        digitalWrite(LED_BUILTIN, HIGH);
        Serial.println("tadas komandas nav");
      }
    }
}
//----------
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  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(F("Failed to read from DHT sensor!"));
  //   return;
  // }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  // Serial.print(F("Humidity: "));
  // Serial.print(h);
  // Serial.print(F("%  Temperature: "));
  // Serial.print(t);
  // Serial.print(F("°C "));
  // Serial.print(f);
  // Serial.print(F("°F  Heat index: "));
  // Serial.print(hic);
  // Serial.print(F("°C "));
  // Serial.print(hif);
  // Serial.println(F("°F"));
}