0% found this document useful (0 votes)
98 views

DHT11 Arduino Program

The program uses an Arduino UNO to read temperature and humidity data from a DHT11 sensor. It controls an RGB LED based on the sensor readings: the green LED glows if the temperature is below 50°C and humidity below 50%; the blue LED glows if temperature is between 50-100°C and humidity above 75%; the red LED glows if temperature is above 100°C and humidity above 90%. If none of these conditions are met, no LED glows.

Uploaded by

kaloy33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

DHT11 Arduino Program

The program uses an Arduino UNO to read temperature and humidity data from a DHT11 sensor. It controls an RGB LED based on the sensor readings: the green LED glows if the temperature is below 50°C and humidity below 50%; the blue LED glows if temperature is between 50-100°C and humidity above 75%; the red LED glows if temperature is above 100°C and humidity above 90%. If none of these conditions are met, no LED glows.

Uploaded by

kaloy33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Write a program for Arduino UNO to read analog temperature and humidity data using

analog read and there is a R-G-B LED as output device. When the temperature value is less
that 50º C and humidity is less than 50% the Green LED should glow. When the
temperature is in between 50 º C to 100º C and humidity is above 75% blue LED should
glow. When the temperature is above 100º C and humidity is above 90% red LED should
glow. If none of these three condition satisfies no LED should glow.

Code:

#include<dht.h>
dht DHT;
float temp;
float hum;
int GREEN=0;
int BLUE=0;
int RED=0;

// if you require to change the pin number, Edit the pin with your
arduino pin.
#define DHT11_PIN 3
void setup()
{
Serial.begin(9600);
Serial.println("welcome to TechPonder Humidity and temperature
Detector");
pinMode(2, OUTPUT); // GREEN LED Connected to D2
pinMode(3, OUTPUT); // BLUE LED Connected to D3
pinMode(4, OUTPUT); // RED LED Connected to D4
}

void loop()
{ // READ DATA
int chk = DHT.read11(DHT11_PIN);
Serial.println(" Humidity " );
Serial.println(DHT.humidity, 1);
Serial.println(" Temparature ");
Serial.println(DHT.temperature, 1);
temp= DHT.humidity;
hum= DHT.temperature;

if(temp<50 && hum <50)


{
GREEN=1;
}
elseif(temp >=50 && temp <100 && hum >75 )
{
GREEN=0;
BLUE=1;
}
elseif(temp > 100 && hum > 90)
{
BLUE=0;
RED=1;
}
else()
{
GREEN=0;
BLUE=0;
RED=0;
}
digitalOut(2,GREEN);
digitalOut(3,BLUE);
digitalOut(4,RED);

delay(2000);
}

You might also like