Page 322 - MDP2022-2
P. 322

주황색O  VCC노랑색O  res갈색
                //attachInterrupt(digitalPinToInterrupt(READ),State1,RISING);
                digitalWrite(SEND,0);
                digitalWrite(3,  LOW);
                delay(500);
                digitalWrite(3,  HIGH);
                u8x8.begin();
            }


            void  loop()
            {
                temp  =  dht.readTemperature();
                humid  =  dht.readHumidity();
                Serial.print("온도  =  ");
                Serial.print(temp);
                Serial.print(",  습도  =  ");
                Serial.println(humid);
                u8x8.setFont(u8x8_font_5x7_f);
                u8x8.setCursor(2,  1);
                u8x8.print("temp=  ");
                u8x8.print(temp,1);
                u8x8.setCursor(2,  2);
                u8x8.print("humid=  ");
                u8x8.print(humid,1);

                long  duration,  distance;
                digitalWrite(TRIG,  LOW);
                delayMicroseconds(2);
                digitalWrite(TRIG,  HIGH);
                delayMicroseconds(10);
                digitalWrite(TRIG,  LOW);
                duration  =  pulseIn  (ECHO,  HIGH);
                distance  =  duration  *  17  /  1000;
                //  Serial.println(duration);
                Serial.print("거리=");
                Serial.print(distance);
                Serial.println("Cm");
                delay(500);

                if(distance  <=  5){
                    Serial.println("5CM  이하  모터  작동  온");
                    digitalWrite(SEND,1);
                }
                if(distance  >  5){
                    digitalWrite(SEND,0);
                }
   317   318   319   320   321   322   323   324   325   326   327