Portfolio. BHSAD Arduino Prototyping | L4, Harduino: Drawing light | Page 19
#include
#include
#define DHTPIN A0
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#define NUM_LEDS 18
#define DATA_PIN 1
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
dht.begin();
}
Weather station with LED strip
Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(“ %\t”);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.println(“ *C”);
}
if (t <= 23) {fill_solid( &(leds[0]),
NUM_LEDS /*number of leds*/,
CRGB::Blue);
FastLED.show();
}
else {
fill_solid( &(leds[0]), NUM_LEDS
/*number of leds*/, CRGB::Red);
FastLED.show();
}
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(t) || isnan(h)) {
Serial.println(“Failed to read from
DHT”);
} else {