Advertisement
ossipee

DHT_DISPLAY_F

Aug 7th, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1.  
  2. #include "DHT.h"  //includes lib for the humdity sensor
  3. #include <LiquidCrystal.h> //lcd lib
  4.  
  5. #define DHTPIN 2 //pin that DHT is connected to
  6. #define DHTTYPE DHT22 //Sensor we are using
  7.  
  8. DHT dht(DHTPIN, DHTTYPE); //defines location for DHT
  9.  
  10. LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  11.  
  12. void setup() {
  13.   // set up the LCD's number of rows and columns:
  14.   lcd.begin(16, 2);
  15.  
  16.  }
  17.  
  18.  
  19. void loop() {
  20.   float h = dht.readHumidity(); //defines the variable for humidity
  21.   float t = dht.readTemperature(); //defines the variable for temperature
  22.   float f = (t * 9.0)/5.0 + 32.0;
  23.   // set the cursor to column 0, line 0
  24.   lcd.setCursor(0,0);
  25.   // print the humidity
  26.   lcd.print("Humidity ");
  27.   lcd.print(h);
  28.   lcd.print(" % ");
  29.   //move line down
  30.   lcd.setCursor(0,1);
  31.   lcd.print("Temp ");
  32.   lcd.print(f);
  33.   lcd.print(" *F");
  34.  
  35.   delay(2000); //wait two sec. before taking another reading.
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement