// // FILE: dht11_test.ino // AUTHOR: Rob Tillaart // VERSION: 0.1.00 // PURPOSE: DHT library test sketch for DHT11 && Arduino // URL: // // Released to the public domain // #include dht DHT; #define DHT11_PIN 0 int dehumidifier = 1; int heater = 2; int led = 3; int i = 0; int ten = 4; int one = 0; void setup() { pinMode(dehumidifier, OUTPUT); pinMode(heater, OUTPUT); pinMode(led, OUTPUT); } void loop() { digitalWrite(led,HIGH); delay(5000); digitalWrite(led,LOW); delay(500); // READ DATA int chk = DHT.read11(DHT11_PIN); int theHumidity = DHT.humidity; int theTemperature = DHT.temperature; //int theHumidity = DHT.humidity; //int theTemperature = DHT.temperature; ten=1; one=1; //=====CHECK WHAT VALUES WE HAVE==== if (theHumidity==40) { ten=4;one=0; } if (theHumidity==41) { ten=4;one=1; } if (theHumidity==42) { ten=4;one=2; } if (theHumidity==43) { ten=4;one=3; } if (theHumidity==44) { ten=4;one=4; } if (theHumidity==45) { ten=4;one=5; } if (theHumidity==46) { ten=4;one=6; } if (theHumidity==47) { ten=4;one=7; } if (theHumidity==48) { ten=4;one=8; } if (theHumidity==49) { ten=4;one=9; } if (theHumidity==50) { ten=5;one=0; } if (theHumidity==51) { ten=5;one=1; } if (theHumidity==52) { ten=5;one=2; } if (theHumidity==53) { ten=5;one=3; } if (theHumidity==54) { ten=5;one=4; } if (theHumidity==55) { ten=5;one=5; } if (theHumidity==56) { ten=5;one=6; } if (theHumidity==57) { ten=5;one=7; } if (theHumidity==58) { ten=5;one=8; } if (theHumidity==59) { ten=5;one=9; } if (theHumidity==60) { ten=6;one=0; } if (theHumidity==61) { ten=6;one=1; } if (theHumidity==62) { ten=6;one=2; } if (theHumidity==63) { ten=6;one=3; } if (theHumidity==64) { ten=6;one=4; } if (theHumidity==65) { ten=6;one=5; } if (theHumidity==66) { ten=6;one=6; } if (theHumidity==67) { ten=6;one=7; } if (theHumidity==68) { ten=6;one=8; } if (theHumidity==69) { ten=6;one=9; } if (theHumidity==70) { ten=7;one=0; } if (theHumidity==71) { ten=7;one=1; } if (theHumidity==72) { ten=7;one=2; } if (theHumidity==73) { ten=7;one=3; } if (theHumidity==74) { ten=7;one=4; } if (theHumidity==75) { ten=7;one=5; } if (theHumidity==76) { ten=7;one=6; } if (theHumidity==77) { ten=7;one=7; } if (theHumidity==78) { ten=7;one=8; } if (theHumidity==79) { ten=7;one=9; } if (theHumidity>79) { ten=8;one=0; } while (ten>0) { digitalWrite(led,HIGH); delay(500); digitalWrite(led,LOW); delay(500); ten--; } digitalWrite(led,LOW); delay(2000); while (one>0) { digitalWrite(led,HIGH); delay(500); digitalWrite(led,LOW); delay(500); one--; } digitalWrite(led,LOW); delay(3000); digitalWrite(led,HIGH); delay(3000); digitalWrite(led,LOW); delay(500); ten=1; one=1; //=====CHECK WHAT TEMPERATURE VALUES WE HAVE==== if (theTemperature==10) { ten=1;one=0; } if (theTemperature==11) { ten=1;one=1; } if (theTemperature==12) { ten=1;one=2; } if (theTemperature==13) { ten=1;one=3; } if (theTemperature==14) { ten=1;one=4; } if (theTemperature==15) { ten=1;one=5; } if (theTemperature==16) { ten=1;one=6; } if (theTemperature==17) { ten=1;one=7; } if (theTemperature==18) { ten=1;one=8; } if (theTemperature==19) { ten=1;one=9; } if (theTemperature==20) { ten=2;one=0; } if (theTemperature==21) { ten=2;one=1; } if (theTemperature==22) { ten=2;one=2; } if (theTemperature==23) { ten=2;one=3; } if (theTemperature==24) { ten=2;one=4; } if (theTemperature==25) { ten=2;one=5; } if (theTemperature==26) { ten=2;one=6; } if (theTemperature==27) { ten=2;one=7; } if (theTemperature==28) { ten=2;one=8; } if (theTemperature==29) { ten=2;one=9; } while (ten>0) { digitalWrite(led,HIGH); delay(500); digitalWrite(led,LOW); delay(500); ten--; } digitalWrite(led,LOW); delay(2000); while (one>0) { digitalWrite(led,HIGH); delay(500); digitalWrite(led,LOW); delay(500); one--; } //============END CHECK VALUES digitalWrite(led,LOW); delay(5000); //if (DHT.humidity>55) { if (theHumidity>55) { digitalWrite(dehumidifier,LOW); } else { digitalWrite(dehumidifier,HIGH); } //if (DHT.temperature<18) { if (theTemperature<18) { digitalWrite(heater,LOW); } else { digitalWrite(heater,HIGH); } i=0; while (i<10) { digitalWrite(led,HIGH); delay(1000); digitalWrite(led,LOW); delay(1000); i++; } } // // END OF FILE //