資源簡介
程序下載即用,如遇光照強度過高可自行在模塊外表添加菲涅爾透鏡,可降低直射光照的影響。

代碼片段和文件信息
/*
SFE_TSL2561?illumination?sensor?library?for?Arduino
Mike?Grusin?SparkFun?Electronics
This?library?provides?functions?to?access?the?TAOS?TSL2561
Illumination?Sensor.
Our?example?code?uses?the?“beerware“?license.?You?can?do?anything
you?like?with?this?code.?No?really?anything.?If?you?find?it?useful
buy?me?a?beer?someday.
version?1.0?2013/09/20?MDG?initial?version
*/
#include?
#include?
SFE_TSL2561::SFE_TSL2561(void)
//?SFE_TSL2561?object
{}
boolean?SFE_TSL2561::begin(void)
//?Initialize?TSL2561?library?with?default?address?(0x39)
//?Always?returns?true
{
return(begin(TSL2561_ADDR));
}
boolean?SFE_TSL2561::begin(char?i2c_address)
//?Initialize?TSL2561?library?to?arbitrary?address?or:
//?TSL2561_ADDR_0?(0x29?address?with?‘0‘?shorted?on?board)
//?TSL2561_ADDR???(0x39?default?address)
//?TSL2561_ADDR_1?(0x49?address?with?‘1‘?shorted?on?board)
//?Always?returns?true
{
_i2c_address?=?i2c_address;
Wire.begin();
return(true);
}
boolean?SFE_TSL2561::setPowerUp(void)
//?Turn?on?TSL2561?begin?integrations
//?Returns?true?(1)?if?successful?false?(0)?if?there?was?an?I2C?error
//?(Also?see?getError()?below)
{
//?Write?0x03?to?command?byte?(power?on)
return(writeByte(TSL2561_REG_CONTROL0x03));
}
boolean?SFE_TSL2561::setPowerDown(void)
//?Turn?off?TSL2561
//?Returns?true?(1)?if?successful?false?(0)?if?there?was?an?I2C?error
//?(Also?see?getError()?below)
{
//?Clear?command?byte?(power?off)
return(writeByte(TSL2561_REG_CONTROL0x00));
}
boolean?SFE_TSL2561::setTiming(boolean?gain?unsigned?char?time)
//?If?gain?=?false?(0)?device?is?set?to?low?gain?(1X)
//?If?gain?=?high?(1)?device?is?set?to?high?gain?(16X)
//?If?time?=?0?integration?will?be?13.7ms
//?If?time?=?1?integration?will?be?101ms
//?If?time?=?2?integration?will?be?402ms
//?If?time?=?3?use?manual?start?/?stop
//?Returns?true?(1)?if?successful?false?(0)?if?there?was?an?I2C?error
//?(Also?see?getError()?below)
{
unsigned?char?timing;
//?Get?timing?byte
if?(readByte(TSL2561_REG_TIMINGtiming))
{
//?Set?gain?(0?or?1)
if?(gain)
timing?|=?0x10;
else
timing?&=?~0x10;
//?Set?integration?time?(0?to?3)
timing?&=?~0x03;
timing?|=?(time?&?0x03);
//?Write?modified?timing?byte?back?to?device
if?(writeByte(TSL2561_REG_TIMINGtiming))
return(true);
}
return(false);
}
boolean?SFE_TSL2561::setTiming(boolean?gain?unsigned?char?time?unsigned?int?&ms)
//?If?gain?=?false?(0)?device?is?set?to?low?gain?(1X)
//?If?gain?=?high?(1)?device?is?set?to?high?gain?(16X)
//?If?time?=?0?integration?will?be?13.7ms
//?If?time?=?1?integration?will?be?101ms
//?If?time?=?2?integration?will?be?402ms
//?If?time?=?3?use?manual?start?/?stop?(ms?=?0)
//?ms?will?be?set?to?integration?time
//?Returns?true?(1)?if?successful?false?(0)?if?there?was?an?I2C?error
//?(Also?see?getError()?below)
{
//?Calculate?ms?for?user
switch?(time)
{
case?0:?ms?=?14;?break;
case?1:?ms?=?101;?break;
case?2:?ms?=?402;?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-03-11?01:15??GY2561\
?????目錄???????????0??2014-08-11?21:50??GY2561\arduino?code\
?????目錄???????????0??2014-08-11?21:50??GY2561\arduino?code\SFE_TSL2561\
?????目錄???????????0??2014-08-11?21:50??GY2561\arduino?code\SFE_TSL2561\examples\
?????目錄???????????0??2014-08-11?21:50??GY2561\arduino?code\SFE_TSL2561\examples\SFE_TSL2561_example\
?????文件????????6467??2013-12-27?14:34??GY2561\arduino?code\SFE_TSL2561\examples\SFE_TSL2561_example\SFE_TSL2561_example.ino
?????文件?????????550??2013-12-27?14:34??GY2561\arduino?code\SFE_TSL2561\keywords.txt
?????文件???????10985??2013-12-27?14:34??GY2561\arduino?code\SFE_TSL2561\SFE_TSL2561.cpp
?????文件????????7155??2013-12-27?14:34??GY2561\arduino?code\SFE_TSL2561\SFE_TSL2561.h
?????文件??????427750??2014-08-04?15:10??GY2561\GY2561-1.JPG
?????文件???????47175??2014-08-11?21:48??GY2561\GY2561_sch.JPG
?????文件??????858830??2018-03-11?01:14??GY2561\TSL2561.en.zh-CN.pdf
?????文件??????432570??2014-06-21?11:51??GY2561\TSL2561.pdf
?????目錄???????????0??2018-03-11?00:37??實驗23?IIC實驗\
?????目錄???????????0??2018-03-11?00:37??實驗23?IIC實驗\CORE\
?????文件???????17273??2010-06-07?10:25??實驗23?IIC實驗\CORE\core_cm3.c
?????文件???????85714??2011-02-09?14:59??實驗23?IIC實驗\CORE\core_cm3.h
?????文件???????15503??2011-03-10?10:52??實驗23?IIC實驗\CORE\startup_stm32f10x_hd.s
?????目錄???????????0??2018-03-11?22:48??實驗23?IIC實驗\HARDWARE\
?????目錄???????????0??2018-03-12?19:12??實驗23?IIC實驗\HARDWARE\IIC\
?????文件????????3071??2018-03-12?19:12??實驗23?IIC實驗\HARDWARE\IIC\myiic.c
?????文件????????1354??2015-04-29?11:46??實驗23?IIC實驗\HARDWARE\IIC\myiic.h
?????目錄???????????0??2018-03-11?00:37??實驗23?IIC實驗\HARDWARE\KEY\
?????文件????????1827??2015-03-20?12:41??實驗23?IIC實驗\HARDWARE\KEY\key.c
?????文件????????1186??2015-03-19?16:14??實驗23?IIC實驗\HARDWARE\KEY\key.h
?????目錄???????????0??2018-03-11?00:37??實驗23?IIC實驗\HARDWARE\LCD\
?????文件???????35016??2015-03-13?14:54??實驗23?IIC實驗\HARDWARE\LCD\font.h
?????文件???????85363??2015-04-24?11:50??實驗23?IIC實驗\HARDWARE\LCD\lcd.c
?????文件????????7529??2015-04-24?11:48??實驗23?IIC實驗\HARDWARE\LCD\lcd.h
?????目錄???????????0??2018-03-11?00:37??實驗23?IIC實驗\HARDWARE\LED\
?????文件????????1298??2012-09-13?13:13??實驗23?IIC實驗\HARDWARE\LED\led.c
............此處省略163個文件信息
- 上一篇:安信可ESP8266安卓手機測試軟件
- 下一篇:Spark快速大數據分析—中文版
評論
共有 條評論