Advertisement
novelli

Arduino/Estufa

May 31st, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2. #include <dht.h>
  3. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  4. dht DHT;
  5. #define dht_dpin A5
  6. int umidade;
  7. const int bd = 7;
  8. const int be = 8;
  9.  
  10. void setup() {
  11.  lcd.begin(16, 2); //LCD
  12.  pinMode(be, INPUT_PULLUP);
  13.  pinMode(bd, INPUT_PULLUP);
  14.  
  15. }
  16.  
  17. void loop() {
  18. umidade = analogRead(A0);
  19. if(digitalRead(be) == LOW){
  20. lcd.clear();
  21. umidade = map(umidade, 1023,350 ,0,100);
  22.   lcd.setCursor(0, 0);
  23.   lcd.print("[H] solo:");
  24.   lcd.setCursor(12, 0);
  25.   lcd.print(umidade);
  26.   lcd.print("%");
  27.   delay(2000);
  28. }
  29.  
  30. if(digitalRead(bd) == LOW)
  31. {
  32.   lcd.clear();
  33.   DHT.read11(dht_dpin); // informações do sensor
  34.    lcd.setCursor(0,1);
  35.   lcd.print("Temp:");
  36.   lcd.setCursor(10,1);
  37.   lcd.print(DHT.temperature);
  38.   lcd.print("C");
  39.   delay(2000);
  40. }
  41. else
  42. {
  43.   lcd.clear();
  44.   lcd.setCursor(0,0);
  45.   lcd.print("Sensores");
  46.   delay(50);
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement