diff options
author | Clemens Fries <git-arduino@xenoworld.de> | 2017-02-23 23:04:29 +0100 |
---|---|---|
committer | Clemens Fries <git-arduino@xenoworld.de> | 2017-02-23 23:04:29 +0100 |
commit | b41eb69e25f9586ab41f8175ccaaff8fdde4e9a4 (patch) | |
tree | d204b0ec6c1ebf00f7a11dde418d57f6c2847219 /humidity-led-indicator | |
parent | ce7de31f275afab6bd28dda4dc1821666866fa61 (diff) |
Humidity indicator LED project
Diffstat (limited to 'humidity-led-indicator')
-rw-r--r-- | humidity-led-indicator/humidity-led-indicator.ino | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/humidity-led-indicator/humidity-led-indicator.ino b/humidity-led-indicator/humidity-led-indicator.ino new file mode 100644 index 0000000..9ecf34c --- /dev/null +++ b/humidity-led-indicator/humidity-led-indicator.ino @@ -0,0 +1,51 @@ +#include <FastLED.h> +#include <Adafruit_Sensor.h> +#include <DHT.h> + +#define DHTPIN 2 // what digital pin we're connected to +#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 +DHT dht(DHTPIN, DHTTYPE); + +const int analogInPin = A0; // Analog input pin that the LDR is attached to + +#define NUM_LEDS 1 +#define DATA_PIN 11 +#define CLOCK_PIN 12 + +CRGB leds[NUM_LEDS]; + +CHSV temp; + +byte counter; + +void setup() +{ + FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN>(leds, NUM_LEDS ); +} + +void loop() +{ + delay(2000); + + int ldrValue = analogRead(analogInPin); + int humidity = dht.readHumidity(); + + if (ldrValue > 1012) { + temp.val = 0; + } else { + temp.val = 255; + } + + if( humidity < 35 ) { + temp.hue = HUE_RED; + } else if(humidity > 60) { + temp.hue = HUE_BLUE; + } else { + temp.hue = map(humidity, 35, 60, HUE_RED, HUE_AQUA); + } + + temp.s = 255; + leds[0] = temp; + FastLED.show(); +} + |