/* * Humidity warning * Contest instructables * Lighting Challence * August 2020 * * Mark Donners * mark.donners@judoles.nl */ // first libary stuff #include #ifdef __AVR__ #include #endif #include #define PIN 8 // serial pin neopixels, change is you connect to other pin #define NUMPIXELS 4 // number of leds ( neopixels) that u are using #define DHT11_PIN 7 // change this to whatever pin u are using to connect to your humidity sensor // Next define some variables to use dht DHT; int r=0; // for the red color of the neopixel int g=0; // for the green color of the neopixel int b=0; // for the blue color of the neopixel Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup(){ Serial.begin(9600); #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif pixels.begin(); // initiate the neopixels pixels.clear(); // make sure all are off after startup } void loop(){ // you can comment the following lines about serial output if you don't need them. int chk = DHT.read11(DHT11_PIN); Serial.print("Temperature = "); Serial.println(DHT.temperature); Serial.print("Humidity = "); Serial.println(DHT.humidity); // now the actual check of humidity and output to the neopixels // humans are most happy when humidity is between 40 and 60%--> green color //When it is above 40%, the color will change to orange //When it is below 40%, the color will change to red if(DHT.humidity<40){r=200;g=0;b=0;} //red color else if(DHT.humidity<60){r=0;g=200;b=0;} // green color else if(DHT.humidity<100){r=200;g=100;b=000;} // orange color for(int i=0; i