Portfolio. BHSAD Arduino Prototyping | L4, Harduino: Drawing light | Page 17
Weather station with RGB LED
#include
#include
#define DHTTYPE DHT11
#define DHTPIN A0
DHT dht(DHTPIN, DHTTYPE);
int redPin = 13;
int grnPin = 11;
int bluPin = 10;
delay(100);
digitalWrite(bluPin, LOW);
}
if((t < 23) && (t > 20.2)) {
digitalWrite(grnPin, HIGH);
delay(100);
digitalWrite(redPin, LOW);
digitalWrite(bluPin, LOW);
}
void setup(){
Serial.begin(9600);
Serial.println(“Humidity and
temperature”);
delay(1000);
pinMode(redPin, OUTPUT);
pinMode(grnPin, OUTPUT);
pinMode(bluPin, OUTPUT);
}
void loop(){
float h = dht.readHumidity();
float t = dht.readTemperature();
if((t < 20) && (t > 17.2)) {
digitalWrite(grnPin, HIGH);
digitalWrite(bluPin, HIGH);
delay(100);
digitalWrite(redPin, LOW);
}
if(t <= 17) {
digitalWrite(bluPin, HIGH);
delay(100);
digitalWrite(grnPin, LOW);
digitalWrite(redPin, LOW);
}
delay(1000);
if((t < 26) && (t >= 23.2)) {
digitalWrite(redPin, HIGH);
digitalWrite(grnPin, HIGH);
}
Serial.print(“Current humidity = “);
Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(“% “);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.println(“C “);