资源简介
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
评论
共有 条评论