Commit f30bbb8c authored by ASAPU SRAVANA PRAGNA's avatar ASAPU SRAVANA PRAGNA

Add new file

parent 79a5b2fd
Pipeline #26236 passed with stage
in 13 seconds
const int LDR = A0; // Defining LDR PIN
int input_val = 0; // Varible to store Input values
#include <dht.h>
dht DHT;
#define DHT11_PIN D0
#define LED D1
int sensorPin = D2;
int sensorValue;
int limit = 50;
void setup()
{
Serial.begin(115200);
pinMode(D3,OUTPUT);
pinMode(LED,OUTPUT);
pinMode(D7, OUTPUT);
}
void loop()
{
ldr();
dht();
soilmoisture();
}
void ldr()
{
input_val = analogRead(LDR); // Reading Input
Serial.println("LDR value is : " );
Serial.println(input_val);
delay(3000);
if(input_val<500)
{
digitalWrite(D3,HIGH);
delay(1000);
}
else
{
digitalWrite(D3,LOW);
delay(1000);
}
}
void dht()
{
DHT.read11(DHT11_PIN);
Serial.println("humidity:");
Serial.print(DHT.humidity);
Serial.println("Temperature:");
Serial.print(DHT.temperature);
if(DHT.temperature>34)
{
digitalWrite(LED,HIGH);
}
else
{
digitalWrite(LED, LOW);
}
delay(3000);
}
void soilmoisture()
{
sensorValue = 100-(((digitalRead(sensorPin))*100)/1024);
Serial.println("soil Value : ");
Serial.print(sensorValue);
if (sensorValue<limit) {
digitalWrite(D7, HIGH);
}
else {
digitalWrite(D7, LOW);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment