Advertisement
ossipee

DHT22 and display

Aug 7th, 2014
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 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.   // set the cursor to column 0, line 0
  23.   lcd.setCursor(0,0);
  24.   // print the humidity
  25.   lcd.print("Humidity ");
  26.   lcd.print(h);
  27.   lcd.print(" % ");
  28.   //move line down
  29.   lcd.setCursor(0,1);
  30.   lcd.print("Temp. ");
  31.   lcd.print(t);
  32.   lcd.print(" *C");
  33.  
  34.   delay(2000); //wait two sec. before taking another reading.
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement