这个小的传感器 透镜 TCS3200D 是能够感知颜色,并寄给 Arduino. 虽然不是很可靠, 它看起来很酷. 它也有 没有镜头的版本.
有 4 指示灯安装在船上.
连接器: S0, S1, S2, S3, 吉安达, VCC, 出和 LED.
还有保护镜头盖.
看看如何用 Arduino 链接.
用于 Arduino 的 3.3 V 电压连接指示灯. 这是很好的亮度.
在这张照片我想读我的订书机的蓝色.
蓝色的结果不是很好, 但我可以看到蓝色的水平稍大.
说到这, 将留给那些想要使用的程序在这里:
int s2Pin = 7;
int s3Pin = 8;
int outPin = 4;
无效的安装程序() {
pinMode(s2Pin, 输出);
pinMode(s3Pin, 输出);
pinMode(outPin, 输入);
开始串行。(9600);
}
int readOutputPulse(int 引脚) {
int count = 0;
虽然 ((digitalRead(PIN) == 1) & (计数 < 32640)) {
计数 ;
}
如果 (计数 = = 32640) 返回计数 2;
计数 = 0; 虽然 ((digitalRead(PIN) == 0) & (计数 < 32640)) {
计数 ;
}
返回计数;
}
int readRed() {
int 脉宽 = 0;
int colorStrength = 0;
digitalWrite(s2Pin, 低);
digitalWrite(s3Pin, 低);
延迟(100);
脉宽 = readOutputPulse(outPin);
colorStrength = (脉宽/128);
colorStrength = (255 - colorStrength);
返回 colorStrength;
}
int readGreen() {
int 脉宽 = 0;
int colorStrength = 0;
digitalWrite(s2Pin, 高);
digitalWrite(s3Pin, 高);
延迟(100);
脉宽 = readOutputPulse(outPin);
colorStrength = (脉宽/128);
colorStrength = (255 - colorStrength);
返回 colorStrength;
}
int readBlue() {
int 脉宽 = 0;
int colorStrength = 0;
digitalWrite(s2Pin, 低);
digitalWrite(s3Pin, 高);
延迟(100);
脉宽 = readOutputPulse(outPin);
colorStrength = (脉宽/128);
colorStrength = (256 - colorStrength);
返回 colorStrength;
}
无效的循环() {
串行.print("R:");
Out.println 串行(readRed());
串行.print("G:");
Out.println 串行(readGreen());
串行.print("(B):");
Out.println 串行(readBlue());
Out.println 串行("");
延迟(500);
}
现在我正在读的计算机上的一个白色的屏幕.
红色的屏幕. 检查传感器是对那种颜色比任何其他更敏感.
一个绿色的屏幕:
最后蓝.
虽然对红色的蓝色或绿色比更敏感, 传感器的工作原理. 也许一些校准有必要更好地工作. 我离开下面的链接与镜头的版本 (易趣) 和没有镜头 (DX):
用透镜 – http://www.ebay.com/sch/i.html?_nkw=tcs3200d+lens&_sacat=0
没有镜头 – http://www.dx.com/p/gy-31-tcs230-tcs3200-color-sensor-recognition-module-blue-black-216,448
一切都来自于在中国购买的中国产品点评网站













您好阿德里亚诺,
感谢您的帮助的文章.
关于代码. 它似乎缺少一些字符?
而 ((digitalRead(销) == 1) & (计数 < 32640)) {
计数 ;
Should this be "count++;"?
而关于这件作品是什么: 如果 (计数 = = 32640) 返回计数 2;
What's between "count" and "2"?