This small sensor Lens TCS3200D is able to perceive colors and send them to the Arduino. Although not very reliable, It seemed very cool. It also has a version without lens.
Has 4 LEDs mounted on board.
The connectors are: S0, S1, S2, S3, GND, VCC, OUT and LED.
There's a cover to protect the lens.
See how was the link with the Arduino.
I used the 3.3 V voltage of the Arduino to connect the leds. It was very good brightness.
In this picture I am trying to read the blue of my stapler.
The results for blue are not very good, but I can see that the Blue level is slightly larger.
Speaking of which, I will leave the program here for those who want to use:
int s2Pin = 7;
int s3Pin = 8;
int outPin = 4;
void setup() {
pinMode(s2Pin, OUTPUT);
pinMode(s3Pin, OUTPUT);
pinMode(outPin, INPUT);
Begin serial.(9600);
}
int readOutputPulse(int pin) {
int count = 0;
While ((digitalRead(PIN) == 1) & (count < 32640)) {
count ;
}
If (count == 32640) return count 2;
count = 0; While ((digitalRead(PIN) == 0) & (count < 32640)) {
count ;
}
return count;
}
int readRed() {
int pulseWidth = 0;
int colorStrength = 0;
digitalWrite(s2Pin, LOW);
digitalWrite(s3Pin, LOW);
delay(100);
pulsewidth = readOutputPulse(outPin);
colorStrength = (pulsewidth/128);
colorStrength = (255 - colorStrength);
return colorStrength;
}
int readGreen() {
int pulseWidth = 0;
int colorStrength = 0;
digitalWrite(s2Pin, HIGH);
digitalWrite(s3Pin, HIGH);
delay(100);
pulsewidth = readOutputPulse(outPin);
colorStrength = (pulsewidth/128);
colorStrength = (255 - colorStrength);
return colorStrength;
}
int readBlue() {
int pulseWidth = 0;
int colorStrength = 0;
digitalWrite(s2Pin, LOW);
digitalWrite(s3Pin, HIGH);
delay(100);
pulsewidth = readOutputPulse(outPin);
colorStrength = (pulsewidth/128);
colorStrength = (256 - colorStrength);
return colorStrength;
}
void loop() {
Serial .print("R:");
Out.println serial(readRed());
Serial .print("G:");
Out.println serial(readGreen());
Serial .print("(B):");
Out.println serial(readBlue());
Out.println serial("");
delay(500);
}
Now I'm reading a white screen on the computer.
A red screen. Check that the sensor is more sensitive to that color than any other.
A green screen:
And finally blue.
Although more sensitive to red than blue or green, the sensor works. Perhaps some calibration is necessary to work better. I leave below link for versions with lens (EBay) and without lens (DX):
With lenses – http://www.ebay.com/sch/i.html?_nkw=tcs3200d+lens&_sacat=0
Without lens – http://www.dx.com/p/gy-31-tcs230-tcs3200-color-sensor-recognition-module-blue-black-216,448
Everything comes from China products reviews site purchased in China













Hello Adriano,
Thanks for you helpful article.
About the code. It seems to be missing some characters?
While ((digitalRead(PIN) == 1) & (count < 32640)) {
count ;
Should this be "count++;"?
And what about this piece: If (count == 32640) return count 2;
What's between "count" and "2"?