Advertisement
ossipee

supercoolernohumid

Aug 13th, 2014
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.71 KB | None | 0 0
  1.  
  2. //ossipee's super cooler code,
  3.  
  4.  
  5.  
  6.  
  7. //add some libraries
  8. #include <DHT.h> //one of many possible DHT22 libs
  9. #include <LiquidCrystal.h> //lcd libs
  10.  
  11. #define DHTPIN 2 //pin that DHT is connected to
  12. #define DHTPIN3 3 //pin that second DHT is connected to
  13. #define DHTTYPE DHT22 //Sensor we are using
  14. #define DHTTYPE3 DHT22 // Second sensor we are using
  15. #define f insideTemp //speariment
  16. #define h insideHumid //
  17. #define f3 outsideTemp //
  18. #define h3 outsideHumid //
  19.  
  20.  
  21. int insideTemp = f;
  22. unsigned int insideHumid = h;
  23.  
  24. int outsideTemp = f3 ;
  25. unsigned int outsideHumid = h3;
  26.  
  27. DHT dht(DHTPIN, DHTTYPE); //defines location for DHT
  28. DHT dht3(DHTPIN3, DHTTYPE); //defines location for second DHT
  29.  
  30. LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  31.  
  32. byte fanrelaypin = 4; // call relay fan pin
  33. byte damperrelaypin = 5; //call relay damper pin
  34.  
  35. void setup() {
  36.   // set up the LCD's number of rows and columns:
  37.   lcd.begin(16, 2);
  38.   pinMode(fanrelaypin, OUTPUT);
  39.   digitalWrite(fanrelaypin, LOW);//start with the relay off
  40.   pinMode(damperrelaypin, OUTPUT);
  41.   digitalWrite(damperrelaypin, LOW);//start with the relay off
  42.  
  43.  }
  44.  
  45. void loop() {
  46.  
  47.   //set cursor to column 0, line 0.
  48.   lcd.setCursor(0,0);
  49.   //print Miracle
  50.   lcd.print("Miracle");
  51.   lcd.setCursor(0,1);
  52.   //print Mechanicals
  53.   lcd.print("Mechanicals");
  54.  
  55.   delay(2000);//wait two seconds before taking readings
  56.  
  57.  
  58.   float h = dht.readHumidity(); //defines the variable for humidity
  59.   float t = dht.readTemperature(1); //defines the variable for temperature. (1)converts C to f
  60.  
  61.  
  62.  
  63.   // set the cursor to column 0, line 0
  64.   lcd.setCursor(0,0);
  65.   // print the humidity
  66.   lcd.print("Humidin ");
  67.   lcd.print(h);
  68.   lcd.print(" % ");
  69.   //move line down
  70.   lcd.setCursor(0,1);
  71.   lcd.print("Tempin ");
  72.   lcd.print(t);
  73.   lcd.print(" *F");
  74.  
  75.  
  76.   delay(2000); //wait two sec. before taking another reading.
  77.  
  78.  
  79.  
  80.   float h3 = dht3.readHumidity(); //defines the variable for humidity
  81.   float t3 = dht3.readTemperature(1); //defines the variable for temperature
  82.  
  83.   // set the cursor to column 0, line 0
  84.   lcd.setCursor(0,0);
  85.   // print the humidity
  86.   lcd.print("Humidout ");
  87.   lcd.print(h3);
  88.   lcd.print(" % ");
  89.   //move line down
  90.   lcd.setCursor(0,1);
  91.   lcd.print("Tempout ");
  92.   lcd.print(t3);
  93.   lcd.print(" *F");
  94.  
  95.  
  96.   if(f < 30 + f3 > 35) // if outside temp less than 30f and cooler warmer than 35f
  97.  
  98.   {
  99.    digitalWrite(damperrelaypin, HIGH); // open exhaust damper
  100.    digitalWrite(fanrelaypin, HIGH); // turn on outside supply air fan
  101.   }
  102.  
  103.   else
  104.  
  105.   {
  106.     digitalWrite(fanrelaypin, LOW);
  107.     digitalWrite(damperrelaypin, LOW);
  108.   }
  109.  
  110.   delay(2000); //wait two sec. before taking another reading.
  111.  
  112.  
  113.  
  114.  
  115.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement