ITE6801 驱动源码和Programming Guide
ite6801 驱动源码和 Programming 手册,The serial programming output ports are not real open-drain drivers. Sink current is guaranteed by I/O design
under the condition of driving the output pin with 0.2V. In a real I 2 C environment, multiple devices and pull-up
resistors could be present on the same bus, rendering the effective pull-up resistance much lower than that
specified by the I 2 C Standard. When set at maximum current, the serial programming output ports of the IT6801FN
are capable of pulling down an effective pull-up resistance as low as 500Ω connected to 5V termination voltage to
the standard I 2 C V IL . When experiencing insufficient low level problem, try setting the current level to higher than
default. Refer to IT6801FN Programming Guide for proper register setting
颜色传感器
#include //包含头文件,这个嘛,就不用多说了~~
#include "L1602.h"
//#define hong 10000
//out接p3.5
sbit tcs230_en=P1^0;
sbit tcs230_s2=P1^1;
sbit tcs230_s3=P1^2;
uint ryz,gyz,byz;
uint rb,gb,bb;
//白平衡子程序
void celiang()
{
//*********求R值************************************
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
TH1=0;
TL1=0;
tcs230_s2=0;
tcs230_s3=0;//选择红色滤光器
tcs230_en=0;
TR0=1;//10毫秒开始计时
TR1=1;//开始计数
while(TF0==0);//等待定时器溢出
TF0=0;//清楚定时器0溢出标志
TR0=0;//关闭定时0
TR1=0;
rb=(unsigned long)(TH1*256+TL1)*255/ryz;
if(rb>255)rb=255;//判断RGB值是否合法
//***********求B值**************************************
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
TH1=0;
TL1=0;
tcs230_s2=0;
tcs230_s3=1;//选择蓝色滤光器
TR0=1;//10毫秒开始计时
TR1=1;//开始计数
while(TF0==0);//等待定时器溢出
TF0=0;//清楚定时器0溢出标志
TR0=0;//关闭定时0
TR1=0;
bb=(unsigned long)(TH1*256+TL1)*255/byz;
if(bb>255)bb=255;//判断RGB值是否合法
//***********求G值**************************************
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
TH1=0;
TL1=0;
tcs230_s2=1;
tcs230_s3=1;//选择绿色滤光器
TR0=1;//10毫秒开始计时
TR1=1;//开始计数
while(TF0==0);//等待定时器溢出
TF0=0;//清楚定时器0溢出标志
TR0=0;//关闭定时0
TR1=0;
tcs230_en=1;
gb=(unsigned long)(TH1*256+TL1)*255/gyz;
if(gb>255)gb=255;//判断RGB值是否合法
}
//******************************************************
//白平衡子程序
void baipingheng()
{
//**************求取红色因子***********************
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
TH1=0;
TL1=0;
tcs230_s2=0;
tcs230_s3=0;//选择红色滤光器
tcs230_en=0;
TR0=1;//10毫秒开始计时
TR1=1;//开始计数
while(TF0==0);//等待定时器溢出
TF0=0;//清楚定时器0溢出标志
TR0=0;//关闭定时0
TR1=0;
ryz=TH1*256+TL1;//其实这里的比例因子应该为255/(TH1*256+TL1)
//**************求取蓝色因子***********************
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;