JS¼¼Êõ

Arduino ÎÂʪ¶È´«¸ÐÆ÷DHT11Ä£¿éʵÑé - ±ÈÌØ×Ö½Ú-ֻΪ¼¼Êõ - ²©¿ÍƵµÀ - CSDN.NET ±ÈÌØ×Ö½Ú-Ö»

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2015-12-15 08:54 ÎÒÒªÆÀÂÛ( )

¡¸¥¢¥¹¥Ú¥¯¥È¥é¥¤¥Ö¥é¥ê¤ò×÷¤ë¡¹¤Ø¤Î×¢ÒâAspectJMaven2 Ç°»Ø¤Þ¤Ç¤Ë¡¢¥¢¥¹¥Ú¥¯¥È¥é¥¤¥Ö¥é¥ê¤Î×÷³É¤ÎÊË·½¤òÒŠ¤Æ¤­¤Þ¤·¤¿¡£ ½ñ»Ø¤Ï¡¢¥¢¥¹¥Ú¥¯¥È¥é¥¤¥Ö¥é¥ê¤Î×÷³É¤Ë

ÍøÉÏÓкܶàDHT11µÄ²âÊÔ£¬ÊÔÁËN¸ö³ÌÐò£¬×ÜÊDz»µÃÒªÁ죬¸÷ÖÖ±¨´í£¬×îºóÖÕÓÚÕÒµ½Ò»Ì׿ÉÓõĿ⡣

Ê×ÏÈÊÇDHT11.hÎļþ

#ifndef __DHT11_H__ #define __DHT11_H__ #include <Arduino.h> //DHT11 IOÉèÖà #define DHT11_DQ 2 #define DHT11_DQ_0 digitalWrite(DHT11_DQ,LOW) #define DHT11_DQ_1 digitalWrite(DHT11_DQ,HIGH) //º¯Êý»òÕß±äÁ¿ÉùÃ÷ extern void DHT11_Init(); extern unsigned char DHT11_Read_Byte(); extern void DHT11_Read(); extern unsigned char HUMI_Buffer_Int; extern unsigned char TEM_Buffer_Int; #endif

Æä´ÎÊÇDHT11.cppÎļþ

#include "DHT11.h" //¶¨Òå±äÁ¿ unsigned char HUMI_Buffer_Int = 0; unsigned char TEM_Buffer_Int = 0; //**************************************************** //³õʼ»¯DHT11 //**************************************************** void DHT11_Init() { pinMode(DHT11_DQ,OUTPUT); DHT11_DQ_0; //À­µÍ×ÜÏߣ¬·¢¿ªÊ¼Ðźţ» delay(30); //ÑÓʱҪ´óÓÚ 18ms£¬ÒÔ±ã DHT11 Äܼì²âµ½¿ªÊ¼Ðźţ» DHT11_DQ_1; delayMicroseconds(40); //µÈ´ý DHT11 ÏìÓ¦£» pinMode(DHT11_DQ,INPUT); while(digitalRead(DHT11_DQ) == HIGH); delayMicroseconds(80); //DHT11 ·¢³öÏìÓ¦£¬À­µÍ×ÜÏß 80us£» if(digitalRead(DHT11_DQ) == LOW); delayMicroseconds(80); //DHT11 À­¸ß×ÜÏß 80us ºó¿ªÊ¼·¢ËÍÊý¾Ý£» } //**************************************************** //¶ÁÒ»¸ö×Ö½ÚDHT11Êý¾Ý //**************************************************** unsigned char DHT11_Read_Byte() { unsigned char i,dat = 0; unsigned int j; pinMode(DHT11_DQ,INPUT); for( i=0; i<8; i++) { if(digitalRead(DHT11_DQ) == LOW) { while(digitalRead(DHT11_DQ) == LOW); //µÈ´ý 50us£» delayMicroseconds(30); //ÅжϸߵçƽµÄ³ÖÐøʱ¼ä£¬ÒÔÅж¨Êý¾ÝÊÇ¡®0¡¯»¹ÊÇ¡®1¡¯£» if(digitalRead(DHT11_DQ) == HIGH) dat |= (1<<(7-i)); //¸ßλÔÚÇ°£¬µÍλÔÚºó£» while(digitalRead(DHT11_DQ) == HIGH); //Êý¾Ý¡®1¡¯£¬µÈ´ýÏÂһλµÄ½ÓÊÕ£» } } return dat; } //**************************************************** //¶ÁÈ¡ÎÂʪ¶ÈÖµ£¬´æ·ÅÔÚTEM_BufferºÍHUMI_Buffer //**************************************************** void DHT11_Read() { DHT11_Init(); HUMI_Buffer_Int = DHT11_Read_Byte(); //¶Áȡʪ¶ÈµÄÕûÊýÖµ DHT11_Read_Byte(); //¶Áȡʪ¶ÈµÄСÊýÖµ TEM_Buffer_Int = DHT11_Read_Byte(); //¶ÁȡζȵÄÕûÊýÖµ DHT11_Read_Byte(); //¶ÁȡζȵÄСÊýÖµ DHT11_Read_Byte(); //¶ÁȡУÑéºÍ delayMicroseconds(50); //DHT11À­µÍ×ÜÏß50us pinMode(DHT11_DQ,OUTPUT); DHT11_DQ_1; //ÊÍ·Å×ÜÏß }

×îºóÊÇÖ÷³ÌÐòÎļþ

#include <Arduino.h> #include "DHT11.h" void setup() //Arduino³ÌÐò³õʼ»¯³ÌÐò·ÅÔÚÕâÀֻÔÚ¿ª»úʱºòÔËÐÐÒ»´Î { Serial.begin(9600); //ÉèÖÃͨѶµÄ²¨ÌØÂÊΪ9600 DHT11_Read(); //¶ÁÈ¡ÎÂʪ¶ÈÖµ delay(200); //µÈ´ý´«¸ÐÆ÷Îȶ¨ } void loop() //Arduino³ÌÐòµÄÖ÷³ÌÐò²¿·Ö£¬Ñ­»·ÔËÐÐÄÚ²¿³ÌÐò { DHT11_Read(); //¶ÁÈ¡ÎÂʪ¶ÈÖµ Serial.print("HUMI = "); Serial.print(HUMI_Buffer_Int); Serial.println(" %RH"); Serial.print("TMEP = "); Serial.print(TEM_Buffer_Int); Serial.println(" C"); delay(1000); //ÑÓʱ1s }
Èý¸öÎļþ±£´æÔÚͬһ¸öÎļþ¼Ð¼´¿É¡£




  • ÉÏһƪArduino ÎÞÔ´·äÃùÆ÷ ÒôÀÖ²¥·ÅʵÑé
  • ÏÂһƪ»ùÓÚACCESSºÍASPµÄSQL¶à¸ö±í²éѯÓë¼ÆËãͳ¼Æ´úÂ루һ£©
  • ¶¥ 0 ²È 0

    ÎÒµÄͬÀàÎÄÕÂ

    ²ÂÄãÔÚÕÒ

    ²é¿´ÆÀÂÛ

    * ÒÔÉÏÓû§ÑÔÂÛÖ»´ú±íÆä¸öÈ˹۵㣬²»´ú±íCSDNÍøÕ¾µÄ¹Ûµã»òÁ¢³¡

    ¸öÈË×ÊÁÏ


    u010435562

  • ·ÃÎÊ£º35137´Î
  • »ý·Ö£º840
  • µÈ¼¶£º

    »ý·Ö£º840

  • ÅÅÃû£ºÇ§ÀïÖ®Íâ
  • ²©Ö÷ÃèÊö

  • Õã½­´óѧ¼ÆËã»úѧԺ¹¤ÒµÉè¼Æ¹¤³Ì˶ʿ£¬Ö÷¹¥»úÆ÷ÊÓ¾õÓ빤ҵÉè¼Æ·½Ïò£¬ÏÖ´ÓÊÂÒ½ÁÆÆ÷еÑз¢¹¤×÷¡£
  • CSDN²©¿Í-±ÈÌØ×Ö½Ú
  • ÐÂÀ˲©¿Í-±ÈÌØ×Ö½Ú
  • ÐÂÀË΢²©-±ÈÌØ×Ö½Ú
  • Áéá½¹¤Òµ¹ÜÀí
  • Áéá½¼¼Êõ
  • ÎÄÕÂËÑË÷

    ÎÄÕ·ÖÀà

  • Âëũ·ÂþÂþ(2)
  • »úÆ÷ÊÓ¾õ(29)
  • ͼÏñ´¦Àí(3)
  • C¡¢C++¡¢C#(7)
  • Êý¾Ý¿â¼¼Êõ(3)
  • Html¡¢Asp¡¢Php(6)
  • Halcon¡¢OpenCV¡¢Matlab(25)
  • Arduino(12)
  • ¹¤ÒµÉè¼Æ(0)
  • ÎÄÕ´浵

    ÔĶÁÅÅÐÐ

  • Visual Studio 10.0ÉèÖÃÒýÓÃHalconDotNet.dll(1943)
  • »ùÓÚACCESSºÍASPµÄSQL¶à¸ö±í²éѯÓë¼ÆËãͳ¼Æ´úÂ루һ£©(1743)
  • Arduino °´¼ü¿ØÖÆÓÐÔ´·äÃùÆ÷(1369)
  • ²âÁ¿Ïð½ºÃÜ·âȦµÄÄÚÍ⾶³ß´ç(1192)
  • Vision China 2013£¨ÉϺ££©Õ¹ÀÀ»á(976)
  • Arduino ¸ºÎ¶ÈϵÊýÈÈÃôµç×裨NTC£©²âÎÂ(954)
  • Ò»¸ö»ùÓڹ̶¨±ÈÀý³ß´çµÄȱÏݼì²âµÄʵÀý¼°Öð²½Í¼Æ¬Ïê½â(897)
  • ·ÖÏí¼ªÁÖ´óѧ»úе¿ÆѧÓ빤³ÌѧԺ²©Ê¿µÄHalconѧϰ¹ý³Ì¼°ÖªÊ¶·ÖÏí(896)
  • Machine Vision Technology Development Trend and Application Cases(894)
  • Ò»¸ö»ùÓڿɱä±ÈÀýµÄÆ¥ÅäµÄʵÀý¼°Ïê½â(824)
  • ¡¡

    1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

    Ïà¹ØÎÄÕÂ
    ÍøÓѵãÆÀ
    Í