Guest User

Untitled

a guest
Dec 14th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. //For the screen
  2. #include <Wire.h>
  3. #include <LiquidCrystal_I2C.h>
  4. LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
  5. //For the sensor
  6. #include <dht.h>
  7. dht DHT;
  8. #define DHT11_PIN 7
  9.  
  10. int led13 = 13;
  11. int led11 = 11;
  12.  
  13. void setup()
  14. {
  15.  
  16. pinMode(led13, OUTPUT);
  17. pinMode(led11, OUTPUT);
  18.  
  19.  
  20. Serial.begin(9600);
  21.  
  22. lcd.begin(16,2);
  23.  
  24. for(int i = 0; i< 3; i++)
  25. {
  26. lcd.backlight();
  27. delay(150);
  28. lcd.noBacklight();
  29. delay(150);
  30. }
  31. lcd.backlight();
  32.  
  33.  
  34. lcd.setCursor(0,0);
  35. lcd.print(" Lets see ");
  36. delay(1000);
  37. lcd.setCursor(0,1);
  38. lcd.print(" the weather! ");
  39. delay(3000);
  40.  
  41. lcd.clear();
  42. lcd.setCursor(0,0);
  43. lcd.print("By Calvin Hobs");
  44. delay(1000);
  45. lcd.setCursor(0,1);
  46. lcd.print("& John Rand");
  47. delay(2000);
  48. }
  49.  
  50.  
  51. void loop()
  52. {
  53. int chk = DHT.read11(DHT11_PIN);
  54. Serial.print("Temperature = ");
  55. Serial.println(DHT.temperature);
  56. Serial.print("Humidity = ");
  57. Serial.println(DHT.humidity);
  58. delay(1000);
  59.  
  60. double f = ((DHT.temperature * 1.8) + 32);
  61. lcd.clear();
  62. lcd.setCursor(0,0);
  63. lcd.print("Temp: ");
  64. lcd.print(f);
  65. lcd.print((char)223);
  66. lcd.print("F");
  67.  
  68.  
  69. lcd.setCursor(0,1);
  70. lcd.print("Humidity: ");
  71. lcd.print(DHT.humidity);
  72. if(DHT.humidity > 20){
  73. digitalWrite(led11, LOW);
  74. digitalWrite(led13, HIGH);
  75.  
  76. }else{
  77. digitalWrite(led13, LOW);
  78. digitalWrite(led11, HIGH);
  79. }
  80. {
  81. if (Serial.available()) {
  82. delay(100);
  83. lcd.clear();
  84. while (Serial.available() > 0) {
  85. lcd.write(Serial.read());
  86. }
  87. }
  88. }
  89.  
  90. }
Add Comment
Please, Sign In to add comment