资源简介
TCS230颜色传感器是业内第一款集成三色识别的颜色传感器,能识别三原色,芯片内集成10位AD,输出为数字信号,采用记频就可以很轻松的将三原色的频率采集,我的程序已经调试通过,相等不错的,请大家放心

代码片段和文件信息
/***********************/
//时间:2010年4月30日
//函数:颜色识别
/*************************/
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
uint fry;
bit int_stop;
uchar l_tmpdate[8];//程序显示的缓冲区
/////显示部分/////
sbit RW_SID=P2^0;//RW
sbit E_CLK=P2^1;//EN
code uchar xianshi1[]=“ 学院物电系 “;
code uchar xianshi2[]=“颜色传感器CS230 “;
code uchar xianshi3[]=“当前颜色为: “;
code uchar xianshi4[]=“当前频率为: “;
code uchar yanse[8]=“蓝绿红百“;
/*********端口定义********/
sbit fs0 =P1^0;
sbit fs1 =P1^1;
sbit en=P1^2;
sbit out=P3^4; //频率从T0口入
sbit fs2 =P1^4;
sbit fs3 =P1^5;
sbit key0=P3^2;
sbit LED0=P3^5;
sbit LED=P2^6;
uchar l_key;
uchar color;
uchar T[5]; //color timer
uchar TH[4];
uchar TL[4];
uchar bizhi[4];
uint comp[3];
uchar flag;
uint disp_datdisp_dat1;
////////////////////
/*******延时函数***********/
void delay(void)//空5个指令
{
_nop_();_nop_();_nop_();_nop_();_nop_();
}
void delayms(uint x)
{
uint y;
for(x;x>0;x--)
for(y=110;y>0;y--);
}
/*void delayms(uint i)
{
for(i=0;i<255;i++);
}*/
/***********串口函数***********/
///////////////////////////////////////////////////
void SendByte(unsigned char dat)//串行发送一字节数据
{
unsigned char i;
for(i=0;i<8;i++)
{
E_CLK=0;
if(dat&0x80)
RW_SID=1;
else
RW_SID=0;
E_CLK=1;
dat=dat<<1;
}
}
////////////////////////////////////////////////////
//写命令
void sendcom(unsigned char dat)
{
SendByte(0xF8);//11111000 RW=0RS=0 同步标志
SendByte(dat&0xF0);//高四位
SendByte((dat&0x0F)<<4);//低四位
}
//写数据
void senddat(unsigned char dat)
{
SendByte(0xFA);//11111010 RW=0RS=1
SendByte(dat&0xF0);//高四位
SendByte((dat&0x0F)<<4);//低四位
}
/***********初始化12864******************/
void init12864()
{
uint i;
sendcom(0x30);//功能设置,一次送8位数据,基本指令集
sendcom(0x0C);//00001100 整体显示,游标off,游标位置off
sendcom(0x01);//00000001 清DDRAM
sendcom(0x02);//00000010 DDRAM地址归位
sendcom(0x80);//10000000 设定DDRAM 7位地址000,0000到地址计数器AC
sendcom(0x80);
delayms(40);
for(i=0;i<16;i++)
{
senddat(xianshi1[i]);
delayms(20);
}
sendcom(0x90);
delayms(40);
for(i=0;i<16;i++)
{
senddat(xianshi2[i]);
delayms(20);
}
sendcom(0x88);
delayms(40);
for(i=0;i<16;i++)
{
senddat(xianshi3[i]);
delayms(20);
}
sendcom(0x98);
delayms(40);
for(i=0;i<16;i++)
{
senddat(xianshi4[i]);
delayms(20);
}
}
/*void display(uchar dat)
{
writedat(0xfadat);
}*/
/******颜色初始化函数*******/
//函数:设置单片机定时计数器工作模式
//功能:选择TCS230输出比例因子,使能输出
/***************************/
/*void init51(void)
{
TMOD=0x11; //工作状态
TH0=256-(50000/256); //定时器初值
TL0=256-(50000%256);
TH1=256-500/256;
TL1=256-500%256; //初始化
ET0=1;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9371 2010-05-16 18:53 颜色识别.c
----------- --------- ---------- ----- ----
9371 1
- 上一篇:OPenGL中绘制茶杯模型
- 下一篇:数学建模资源分配问题
相关资源
- 循迹小车51程序(超声波 颜色识别 舵
- stm32f4+ov5640颜色识别.zip
- stm32f4 摄像头颜色识别
- stm32f407+ov5640颜色识别与追踪
- stm32f103zet6+摄像头颜色识别
- tcs230颜色识别传感器
- opencv依靠颜色识别和跟踪物体
- Pixy源码及HSV移植
- 基于颜色识别的火焰检测算法的open
- stm32陀螺仪,颜色识别抓球小车.zip
- 颜色识别程序stm32f103使用tcs3200含上位
- OV7725颜色识别
- 颜色识别及定位
- 车辆检测基础-红色车辆检测
- stm32+ov7670+颜色识别追踪
- TCS3200通过串口查看颜色识别结果带接
- 基于STM32F407和OV5640的视觉算法二维码
- stm32的APDS9960颜色识别、舵机、电机
- OV7670摄像头多块颜色识别追踪并串口
- 颜色识别中各颜色阈值快速查找小程
- RGB图像处理+颜色识别
- 基于opencv颜色识别 - 图像(普通轮廓
- pixy 算法分析
- OV7725摄像头液晶颜色识别
- 基于openmv和舵机机械臂的物料颜色识
- TCS3200颜色传感器Arduino优化代码快速识
- TCS230颜色识别传感器 原理 资料 程序
- stm32颜色识别追踪算法 腐蚀算法
- STM32 颜色识别代码
- STM32 TCS3200颜色识别 超声波 PWM 程序源
评论
共有 条评论