Advertisement
Guest User

DHT Servo

a guest
Sep 29th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include "DHT.h"
  2. #include <LiquidCrystal.h>
  3. #include <Servo.h>// inclui biblioteca de manipulação de servos motores.
  4.  
  5.  
  6. #define DHTPIN 2 // what pin we're connected to
  7.  
  8. #define DHTTYPE DHT22
  9.  
  10. DHT dht(DHTPIN, DHTTYPE);
  11. LiquidCrystal lcd(8,9,4,5,6,7);
  12.  
  13. Servo motor;
  14.  
  15. void setup(void) {
  16.  
  17. motor.attach(13);
  18. lcd.begin(16, 2);
  19. lcd.print("Reading sensor");
  20. dht.begin();
  21.  
  22. }
  23.  
  24. void loop() {
  25.  
  26. float temperature, humidity;
  27.  
  28. humidity = dht.readHumidity();
  29. temperature = dht.readTemperature();
  30. delay(2000);
  31.  
  32. lcd.clear();
  33.  
  34. char tempF[6];
  35. char humF[6];
  36. dtostrf(temperature, 5, 1, tempF);
  37. dtostrf(humidity, 2, 0, humF);
  38.  
  39. lcd.print("T:");
  40. lcd.print(tempF);
  41. lcd.print((char)223);
  42. lcd.print("C ");
  43. lcd.print("H: ");
  44. lcd.print(humF);
  45. lcd.print("%");
  46.  
  47.  
  48.  
  49. //principal
  50. motor.write(0); //aqui o motor ficará a 0 graus
  51. delay(50000); //5 minutos
  52. motor.write(90); //aqui o motor ficará em 90 graus
  53. delay(50000); // espera 5 minutos
  54. motor.write(180); //aqui o motor ficará a 0 graus
  55. delay(50000); // espere 5 minutos
  56. motor.write(90); //aqui o motor ficará em 180 graus
  57. delay(50000); // espere 5 minutos
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement