Portfolio. BHSAD Arduino Prototyping | L4, Harduino: Drawing light | Page 20
station basic Prototype: dht11, lcd, led strip
#include
#include
#include
#define DHTPIN A0
#define DHTTYPE DHT11
LiquidCrystal lcd(13, 12, 11,
10, 9, 8);
DHT dht(DHTPIN,
DHTTYPE);
#define NUM_LEDS 18
#define DATA_PIN 3
else {
lcd.setCursor(0, 0);
lcd.print(h);
lcd.print(“ % “);
lcd.setCursor(0, 1);
lcd.print(t);
lcd.print(“ C”);
}
void setup() { if (t <= 20) {fill_solid(
&(leds[0]), NUM_LEDS
/*number of leds*/,
CRGB::Blue);
FastLED.show();
}
lcd.begin(16, 2);
dht.begin();
FastLED.
addLeds(leds, NUM_
LEDS); else {
fill_solid( &(leds[0]),
NUM_LEDS /*number of
leds*/, CRGB::Red);
FastLED.show();
}
} }
CRGB leds[NUM_LEDS];
void loop() {
float h = dht.
readHumidity();
float t = dht.
readTemperature();
if (isnan(t) || isnan(h)) {
lcd.print(“NO
CONNECTION”);
return;
}
delay(1000);