資源簡介
支持1206,紅外模塊,超聲波模塊,LED點陣,舵機模塊,溫度模塊

代碼片段和文件信息
//
//????FILE:?dht.cpp
//??AUTHOR:?Rob?Tillaart
//?VERSION:?0.1.22
//?PURPOSE:?DHT?Temperature?&?Humidity?Sensor?library?for?Arduino
//?????URL:?http://arduino.cc/playground/Main/DHTLib
//
//?HISTORY:
//?0.1.22?undo?delayMicroseconds()?for?wakeups?larger?than?8
//?0.1.21?replace?delay?with?delayMicroseconds()?+?small?fix
//?0.1.20?Reduce?footprint?by?using?uint8_t?as?error?codes.?(thanks?to?chaveiro)
//?0.1.19?masking?error?for?DHT11?-?FIXED?(thanks?Richard?for?noticing)
//?0.1.18?version?1.16/17?broke?the?DHT11?-?FIXED
//?0.1.17?replaced?micros()?with?adaptive?loopcount
//????????removed?DHTLIB_INVALID_VALUE
//????????added??DHTLIB_ERROR_CONNECT
//????????added??DHTLIB_ERROR_ACK_L??DHTLIB_ERROR_ACK_H
//?0.1.16?masking?unused?bits?(less?errors);?refactored?bits[]
//?0.1.15?reduced?#?micros?calls?2->1?in?inner?loop.
//?0.1.14?replace?digital?read?with?faster?(~3x)?code?=>?more?robust?low?MHz?machines.
//
//?0.1.13?fix?negative?temperature
//?0.1.12?support?DHT33?and?DHT44?initial?version
//?0.1.11?renamed?DHTLIB_TIMEOUT
//?0.1.10?optimized?faster?WAKEUP?+?TIMEOUT
//?0.1.09?optimize?size:?timeout?check?+?use?of?mask
//?0.1.08?added?formula?for?timeout?based?upon?clockspeed
//?0.1.07?added?support?for?DHT21
//?0.1.06?minimize?footprint?(2012-12-27)
//?0.1.05?fixed?negative?temperature?bug?(thanks?to?Roseman)
//?0.1.04?improved?readability?of?code?using?DHTLIB_OK?in?code
//?0.1.03?added?error?values?for?temp?and?humidity?when?read?failed
//?0.1.02?added?error?codes
//?0.1.01?added?support?for?Arduino?1.0?fixed?typos?(31/12/2011)
//?0.1.00?by?Rob?Tillaart?(01/04/2011)
//
//?inspired?by?DHT11?library
//
//?Released?to?the?public?domain
//
#include?“dht.h“
/////////////////////////////////////////////////////
//
//?PUBLIC
//
int8_t?dht::read11(uint8_t?pin)
{
????//?READ?VALUES
????int8_t?result?=?_readSensor(pin?DHTLIB_DHT11_WAKEUP?DHTLIB_DHT11_LEADING_ZEROS);
????//?these?bits?are?always?zero?masking?them?reduces?errors.
????bits[0]?&=?0x7F;
????bits[2]?&=?0x7F;
????//?CONVERT?AND?STORE
????humidity????=?bits[0];??//?bits[1]?==?0;
????temperature?=?bits[2];??//?bits[3]?==?0;
????//?TEST?CHECKSUM
????//?bits[1]?&&?bits[3]?both?0
????uint8_t?sum?=?bits[0]?+?bits[2];
????if?(bits[4]?!=?sum)
????{
????????return?DHTLIB_ERROR_CHECKSUM;
????}
????return?result;
}
int8_t?dht::read(uint8_t?pin)
{
????//?READ?VALUES
????int8_t?result?=?_readSensor(pin?DHTLIB_DHT_WAKEUP?DHTLIB_DHT_LEADING_ZEROS);
????//?these?bits?are?always?zero?masking?them?reduces?errors.
????bits[0]?&=?0x03;
????bits[2]?&=?0x83;
????//?CONVERT?AND?STORE
????humidity?=?(bits[0]*256?+?bits[1])?*?0.1;
????temperature?=?((bits[2]?&?0x7F)*256?+?bits[3])?*?0.1;
????if?(bits[2]?&?0x80)??//?negative?temperature
????{
????????temperature?=?-temperature;
????}
????//?TEST?CHECKSUM
????uint8_t?sum?=?bits[0]?+?bits[1]?+?bits[2]?+?bits[3];
????if?(bits[4]?!=?sum)
????{
????????return?DHTLIB_ERROR_CHECKSUM;
????}
????return?result;
}
/////////////////////////////////////////////////////
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-15?17:20??block\
?????文件??????111736??2018-11-19?14:53??block\yfrobot.js
?????目錄???????????0??2017-12-15?17:20??generator\
?????文件???????51933??2018-11-19?15:46??generator\yfrobot.js
?????目錄???????????0??2017-12-15?17:20??language\
?????目錄???????????0??2017-12-15?17:20??language\yfrobot\
?????文件????????4425??2018-11-19?14:52??language\yfrobot\en.js
?????文件????????4564??2018-11-19?14:52??language\yfrobot\spa.js
?????文件????????4423??2018-11-19?14:52??language\yfrobot\zh-hans.js
?????文件????????4424??2018-11-19?14:52??language\yfrobot\zh-hant.js
?????目錄???????????0??2018-09-18?13:53??media\
?????目錄???????????0??2018-11-12?16:56??media\yfrobot\
?????文件???????33140??2018-11-07?15:54??media\yfrobot\yf_298P.png
?????文件???????11063??2018-11-03?09:01??media\yfrobot\yf_btn.png
?????文件???????10136??2018-11-03?09:02??media\yfrobot\yf_buzzer.png
?????文件???????10010??2018-11-03?09:03??media\yfrobot\yf_buzzer_p.png
?????文件???????11245??2018-11-03?09:04??media\yfrobot\yf_collision.png
?????文件???????20442??2018-07-10?16:54??media\yfrobot\yf_dht11.png
?????文件???????22848??2018-07-10?16:55??media\yfrobot\yf_dht22.png
?????文件???????31498??2018-05-24?16:08??media\yfrobot\yf_dotMatrix.png
?????目錄???????????0??2018-10-31?15:38??media\yfrobot\yf_dotMatrix_img\
?????目錄???????????0??2018-10-31?09:49??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\
?????文件???????35906??2018-10-27?16:57??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_bearPaw.png
?????文件???????33672??2018-10-29?15:07??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_bearPaw2.png
?????文件???????35540??2018-10-29?15:07??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_bearPaw3.png
?????文件???????34256??2018-10-29?15:07??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_bearPaw4.png
?????文件???????36834??2018-10-27?16:56??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_butterfly.png
?????文件???????35704??2018-10-27?16:58??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_camel.png
?????文件???????35093??2018-10-27?16:50??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_cat.png
?????文件???????37439??2018-10-27?16:53??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_cattle.png
?????文件???????37293??2018-10-27?16:50??media\yfrobot\yf_dotMatrix_img\yf_dotMatrix_animal\yf_dotMatrix_chick.png
............此處省略245個文件信息
- 上一篇:新華三模擬測試軟件
- 下一篇:IEC61508英文版2010
評論
共有 條評論