TCS3200是彩色光到频转换器芯片,可通过微控制器编程。该模块可用于通过诸如Arduino等集成的微控制器检测白光的所有7种颜色。
在这篇文章中,我们将看看RGB颜色传感器TCS3200,我们将了解颜色传感器的工作原理,我们将使用Arduino测试TCS3200传感器并提取一些有用的数据。
Importance of Color Recognition
We see the world every day, filled with rich colors, have you ever wondered what actually colors are apart from visually feeling it. Well, colors are electromagnetic wave with different wavelengths. Red, Green, Blue has different wavelengths, human eyes are tuned to pick up these RGB colors, which is a narrow band from electromagnetic spectrum.
但是,我们看到的不仅仅是红色,蓝色和绿色;那是因为我们的大脑可以混合两种或更多种颜色并发出新的颜色。
The ability to see different colors helped the ancient human civilization to escape from life threatening dangers such as animals and also help identifying edible items such as fruits at its right growth, which will be pleasant to consume.
Women are better at recognizing different shades of color (better color sensitive) than man, but men are better at tracking fast moving objects and react accordingly.
许多研究表明,这是因为在g ancient period; men go for hunting because of their physical strength which was superior to women.
Women are honored with less risky task such as collecting fruits and other edible items from plants and trees.
从植物处收集其正确的生长(水果颜色发挥着巨大作用的颜色)对于良好的消化来说非常重要,这有助于人类在海湾的健康问题。
这些男性和女性视觉能力的这些差异甚至在现代持续存在。
好的,为什么以上解释电子颜色传感器?好吧,因为颜色传感器是基于人眼的颜色模型制造的,而不是任何其他动物的眼睛颜色模型。
For example, dual cameras in smartphones; one of the cameras is specifically made for recognizing RGB colours and other camera for taking normal images. Blending these two images / information with some careful algorithm will reproduce accurate colors of real object on screen only which humans can perceive.
注意:并非所有双相机都以与上述相同的方式工作,其中一些用于光学缩放;有些用于产生深入的场效应等。
Now let’s see how TCS3200 colour sensors are fabricated.
Illustration of TCS3200 sensor:
It has 4 built in white LEDs for illuminating the object. It has 10 pins; two Vcc and GND pins (use any two of these). The function of S0, S1, S2, S3, S4 and ‘out’ pin will be explained shortly.
如果仔细查看传感器,我们可以看到如下所示的东西:
它有8 x 8个颜色传感器,共64个。光传感器块具有红色,蓝色,绿色传感器。通过在传感器上施加不同的滤色器来形成不同的彩色传感器。在64中,它有16个蓝色,16个绿色,16个红色传感器,有16个照片传感器没有任何滤色器。
蓝色滤色器仅允许蓝色彩色光击中传感器并拒绝其余的波长(颜色);这对于其他两个颜色传感器相同。
如果你施ne a blue light on a red filter or green filter, less intense light will pass through the green or red filters compare to blue filter. So the blue filtered sensor will receive more light compare to other two.
So, we can put the colour sensors with RGB filters in a block and shine any coloured light, and the relevant colour sensor will receive more light than other two.
通过测量在传感器处接收的光的强度可以揭示光线闪耀的颜色。
将来自传感器的信号接口到微控制器的光强度与变频器进行。
Circuit Block Diagram
“out”引脚是输出。输出引脚的频率为50%占空比。S2和S3引脚是光传感器的选择线。
你通过寻找制表来了解更好的优势:
通过将低信号施加到引脚S2和S3将选择红色传感器并测量红色波长的强度。
Similarly, follow the above tabulation for rest of the colors.
In general Red, blue and green sensors are measured leaving the sensors one without filters.
The S0 and S1 are the frequency scaling pins:
S0 and S1 are frequency scaling pins to scale the output frequency. The frequency scaling is used to select the optimum output frequency from sensor to the microcontroller. In case of Arduino 20% is recommended, S0 ‘HIGH’ and S1 ‘LOW’.
The output frequency goes high if the light intensity of the relevant sensor is high. For simplicity of the program code the frequency is not measured, but the pulse duration is measured, higher the frequency less the pulse duration.
So, the one which on the serial monitor readings shows the least has to be the color which is placed in front of sensor.
Extracting Data from the Color Sensor
Now let’s practically try and extract data from the sensor:
计划代码:
// -------------由r.girish开发的计划------------- //
const int s0 = 4;
const int s1 = 5;
const int s2 = 6;
const int s3 = 7;
const int out = 8;
int frequency1 = 0;
int surford2 = 0;
int frequency3 = 0;
int状态=低;
int state1 = LOW;
int state2 = HIGH;
void setup()
{
Serial.begin(9600);
PINMODE(S0,输出);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
PINMODE(S3,输出);
pinMode(out, INPUT);
// ----缩放频率20%----- //
DigitalWrite(S0,State2);
DigitalWrite(S1,State1);
// --------------------------- //
}
void loop()
{
// -----感测红色----- //iptiquewrite(S2,endy1);
DigitalWrite(S3,State1);
frequency1 = pulseIn(out, state);
Serial.print("RED = ");
serial.print(频率1);
Serial.print(" |");
延迟(100);
// ------传感绿色---- //
DigitalWrite(S2,State2);
DigitalWrite(S3,State2);
频率2 =脉冲(out,状态);
Serial.print(" Green = ");
serial.print(频率2);
Serial.print(" |");
延迟(100);
// ------传感蓝色---- //
digitalWrite(s2, state1);
DigitalWrite(S3,State2);
frequency3 = pulseIn(out, state);
serial.print(“blue =”);
Serial.println(frequency3);
延迟(100);
serial.println(“------------------------------------”);
延迟(400);
}
// -------------由r.girish开发的计划------------- //
Serial monitor OUTPUT:
显示最低的读取是放置在传感器前面的颜色。您还可以编写用于识别任何颜色的代码,例如黄色。黄色是融合绿色和红色的结果,如果将黄色放在传感器的前面,则必须考虑红色和绿色传感器读数,同样适用于任何其他颜色。
如果您对使用Arduino文章有关此RGB颜色传感器TCS3200的任何疑问,请在评论部分中表达。您可能会收到快速回复。
The above explained color sensor can be also used fortriggering an external gadget though a relayfor executing a desired operation.
Farhansays
现在可以通过获得绿色光线来使继电器脱离?
赃物says
GR先生很快就会回答你的问题......
grsays
Hi Farhan,
我将提出一篇文章,解释了如何通过检测特定颜色来触发中继的文章。
问候
Ellasays
Tried this one but it doesnt recognize the color of fruits… Ex it cannot state that the apple is red and the leaves are green it can only detect solid colors of objects not fruits.
赃物says
yes the sensor may not be that efficient, this has been notified at the end of this subsequent article:
//www.addme-blog.com/2017/09/relay-trigger-by-color-detection-using-arduino.html