資源簡介
37款傳感器套件資料+說明書(溫度、濕度、紅外、震動、火焰、開關、聲音、霍爾傳感器等)
代碼片段和文件信息
//?This?library?is?free?software;?you?can?redistribute?it?and/or
//?modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
//?License?as?published?by?the?Free?Software?Foundation;?either
//?version?2.1?of?the?License?or?(at?your?option)?any?later?version.
#include?“DallasTemperature.h“
extern?“C“?{
??#include?“WConstants.h“
}
DallasTemperature::DallasTemperature(OneWire*?_oneWire)
??#if?REQUIRESALARMS
??:?_AlarmHandler(&defaultAlarmHandler)
??#endif
{
??_wire?=?_oneWire;
??devices?=?0;
??parasite?=?false;
??bitResolution?=?9;
??waitForConversion?=?true;
}
//?initialize?the?bus
void?DallasTemperature::begin(void)
{
??DeviceAddress?deviceAddress;
??_wire->reset_search();
??devices?=?0;?//?Reset?the?number?of?devices?when?we?enumerate?wire?devices
??while?(_wire->search(deviceAddress))
??{
????if?(validAddress(deviceAddress))
????{
??????if?(!parasite?&&?readPowerSupply(deviceAddress))?parasite?=?true;
??????ScratchPad?scratchPad;
??????readScratchPad(deviceAddress?scratchPad);
??bitResolution?=?max(bitResolution?getResolution(deviceAddress));
??????devices++;
????}
??}
}
//?returns?the?number?of?devices?found?on?the?bus
uint8_t?DallasTemperature::getDeviceCount(void)
{
??return?devices;
}
//?returns?true?if?address?is?valid
bool?DallasTemperature::validAddress(uint8_t*?deviceAddress)
{
??return?(_wire->crc8(deviceAddress?7)?==?deviceAddress[7]);
}
//?finds?an?address?at?a?given?index?on?the?bus
//?returns?true?if?the?device?was?found
bool?DallasTemperature::getAddress(uint8_t*?deviceAddress?uint8_t?index)
{
??uint8_t?depth?=?0;
??_wire->reset_search();
??while?(depth?<=?index?&&?_wire->search(deviceAddress))
??{
????if?(depth?==?index?&&?validAddress(deviceAddress))?return?true;
????depth++;
??}
??return?false;
}
//?attempt?to?determine?if?the?device?at?the?given?address?is?connected?to?the?bus
bool?DallasTemperature::isConnected(uint8_t*?deviceAddress)
{
??ScratchPad?scratchPad;
??return?isConnected(deviceAddress?scratchPad);
}
//?attempt?to?determine?if?the?device?at?the?given?address?is?connected?to?the?bus
//?also?allows?for?updating?the?read?scratchpad
bool?DallasTemperature::isConnected(uint8_t*?deviceAddress?uint8_t*?scratchPad)
{
??readScratchPad(deviceAddress?scratchPad);
??return?(_wire->crc8(scratchPad?8)?==?scratchPad[SCRATCHPAD_CRC]);
}
//?read?device‘s?scratch?pad
void?DallasTemperature::readScratchPad(uint8_t*?deviceAddress?uint8_t*?scratchPad)
{
??//?send?the?command
??_wire->reset();
??_wire->select(deviceAddress);
??_wire->write(READSCRATCH);
??//?TODO?=>?collect?all?comments?&??use?simple?loop
??//?byte?0:?temperature?LSB??
??//?byte?1:?temperature?MSB
??//?byte?2:?high?alarm?temp
??//?byte?3:?low?alarm?temp
??//?byte?4:?DS18S20:?store?for?crc
??//?????????DS18B20?&?DS1822:?configuration?register
??//?byte?5:?internal?use?&?crc
??//?byte?6:?DS18S20:?COUNT_REMAIN
??//?????????DS18B20?&?DS18
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-08-05?13:23??3mm雙色LED模塊\
?????文件??????212927??2014-08-05?13:23??3mm雙色LED模塊\3mm雙色LED模塊.pdf
?????目錄???????????0??2014-08-05?13:23??3色LED模塊\
?????文件??????215849??2014-08-05?13:23??3色LED模塊\3色LED模塊.pdf
?????目錄???????????0??2014-08-05?14:05??3色LED模塊(RGB)\
?????目錄???????????0??2014-08-05?13:23??3色LED模塊(RGB)\3mm雙色LED模塊\
?????文件??????212927??2014-08-05?13:24??3色LED模塊(RGB)\3mm雙色LED模塊\3mm雙色LED模塊.pdf
?????文件??????209571??2014-08-05?13:24??3色LED模塊(RGB)\3色LED模塊(RGB).pdf
?????目錄???????????0??2014-08-05?13:23??5mm?紅綠雙色?LED(共陰)模塊\
?????文件??????246277??2014-08-05?13:24??5mm?紅綠雙色?LED(共陰)模塊\5mm?紅綠雙色?LED(共陰)模塊?.pdf
?????目錄???????????0??2014-08-05?13:23??7彩自動閃爍LED模塊\
?????文件??????196174??2014-08-05?13:25??7彩自動閃爍LED模塊\7彩自動閃爍LED模塊.pdf
?????目錄???????????0??2014-08-05?13:23??Arduino?繼電器\
?????文件?????2110888??2014-08-05?13:25??Arduino?繼電器\Arduino?繼電器.pdf
?????目錄???????????0??2014-08-05?13:23??傾斜開關\
?????文件??????194934??2014-08-05?13:33??傾斜開關\傾斜開關.pdf
?????目錄???????????0??2014-08-05?13:23??光敏電阻\
?????文件?????2167500??2014-08-05?13:27??光敏電阻\光敏電阻.pdf
?????目錄???????????0??2014-08-05?13:23??光遮斷模塊\
?????文件?????????408??2013-06-25?10:15??光遮斷模塊\光遮斷.txt
?????文件??????192787??2014-08-05?13:27??光遮斷模塊\光遮斷模塊.pdf
?????目錄???????????0??2014-08-05?13:23??雙軸XY搖桿\
?????目錄???????????0??2013-07-11?15:52??雙軸XY搖桿\yaogang\
?????文件?????????367??2013-06-25?10:15??雙軸XY搖桿\yaogang\yaogang.pde
?????文件?????1569822??2014-08-05?13:35??雙軸XY搖桿\游戲搖桿模塊.PDF
?????目錄???????????0??2014-08-05?13:23??大磁簧模塊\
?????文件??????207809??2014-08-05?13:26??大磁簧模塊\大磁簧模塊.pdf
?????目錄???????????0??2014-08-05?13:23??循跡模塊\
?????文件??????197418??2014-08-05?13:38??循跡模塊\循線模塊.pdf
?????目錄???????????0??2014-08-05?13:23??手指偵測心跳模塊\
?????目錄???????????0??2013-07-11?15:52??手指偵測心跳模塊\Project_12_pulse_monitor_test\
............此處省略111個文件信息
- 上一篇:DASMBSerial_2.0
- 下一篇:射頻功率到各種電壓的換算P_V.xls
評論
共有 條評論