#include <DHT.h>
#define DHTPIN 7 // Mention the digital pin where you connected
#define DHTTYPE DHT22 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
int ledPin = 14;
int ldrPin = A0;
int distance = 7;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
Serial.begin(9600);
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
if (distance < 7) {
int ldrStatus = analogRead(ldrPin);
Serial.println(ldrStatus);
}
else {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Temperature : ");
Serial.print(t);
Serial.print(" Humidity : ");
Serial.println(h);
//Serial.println("Distance is more than 7");
}
}