TCS3200 color sensor don't work

I have just got the TCS3200 color sensor and having problems with it. The LEDs on the sensor don't light up. But if I take my finger under the pins on the vcc and ground side and lift up, then the LEDs light up. But I don't get any reasnoble values. If I don't use my finger I get zero on all values. But if I use my finger and try it on a red paper, I seem to get random number, most zeros. But also some values that er a couple of thousands, or even negative a couple of thousands. And besides the values comes out much faster when I hold my finger.
This is the code I am using:
#define S0 4
#define S1 5
#define S2 6
#define S3 7
#define sensorOut 8
int frequency = 0;
void setup() {
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);

// Setting frequency-scaling to 20%
digitalWrite(S0,HIGH);
digitalWrite(S1,LOW);

Serial.begin(9600);
}
void loop() {
// Setting red filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
// Printing the value on the serial monitor
Serial.print("R = ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.print(" ");
delay(100);
// Setting Green filtered photodiodes to be read
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
// Printing the value on the serial monitor
Serial.print("G = ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.print(" ");
delay(100);
// Setting Blue filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
// Printing the value on the serial monitor
Serial.print("B = ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.println(" ");
delay(100);
}

somewhere in your code you have to tell the LEDs to be on and at what intensity the sensor output will always be a range of output frequencies you have to tell computer if output is within a set range what color it is.

colorSensor.ledStatus = 1; // When turn on the color sensor LED, ledStatus = 1; When turn off the color sensor LED, ledStatus = 0.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.