safwan092

digispark-dht11-motor-transistor

Jul 18th, 2020
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <DHT.h>    //dht sensor library
  2. DHT dht(4, DHT11);  //sensor pin=4, dht type=dht11
  3. int motor = 3;
  4.  
  5. void setup()
  6. {
  7.   dht.begin();
  8.   pinMode(motor,OUTPUT);
  9.   digitalWrite(motor,LOW);
  10. }
  11.  
  12. void loop() {
  13.  
  14.   float t = dht.readTemperature();
  15.   float h = dht.readHumidity();
  16.  
  17.   if(h>60){
  18.     digitalWrite(motor,HIGH);
  19.     delay(2000); // wait for 2 seconds
  20.     digitalWrite(motor,LOW);
  21.     delay(2000); // wait for 2 seconds
  22.   }
  23.  
  24. }
RAW Paste Data