Page 210 - 최강 아두이노 퍼스트 참고서
P. 210

SCL                    A5


               예제코드)

               http://www.allfirst.co.kr/pds/arduinoLib/dht11_ex_1.ino



                 #include <dht.h>
                 #include <Wire.h>
                 #include <LiquidCrystal_I2C.h>

                 #define DHT11_PIN 8


                 dht DHT;
                 //LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
                 LiquidCrystal_I2C lcd(0x27,16,2);

                 void setup() {
                   Serial.begin(9600);   lcd.init();
                   lcd.backlight();

                 }

                 int getDHT(int& t, int &h)
                 {
                   int chk = DHT.read11(DHT11_PIN);
                   switch (chk)
                   {
                     case DHTLIB_OK:
                       Serial.print("OK,\t");
                       break;
                     case DHTLIB_ERROR_CHECKSUM:
                       Serial.print("Checksum error,\t");
                       break;
                     case DHTLIB_ERROR_TIMEOUT:
                       Serial.print("Time out error,\t");
                       break;
                     case DHTLIB_ERROR_CONNECT:
                       Serial.print("Connect error,\t");
                       break;
                     case DHTLIB_ERROR_ACK_L:
                       Serial.print("Ack Low Error,\t");
                       break;
                     case DHTLIB_ERROR_ACK_H:
                       Serial.print("Ack High Error,\t");
                       break;





                                                   210
   205   206   207   208   209   210   211   212   213   214   215