From my calculations, via the pulseIn()
function, I receive frequency values 2, 4, 4, 3 microseconds for clear, red, green and blue, respectively. The resulting wavelengths are very high.
Here is the obtainColor()
function that captures those frequencies.
void obtainColor() {
unsigned long clear, red, green, blue;
TCS3200_on();
noFilter();
clear = pulseIn(OUT,LOW,10000);
// print function for clear (I do this for the rest of the colors)
Serial.print("C:")
Serial.print(clear);
redFilter();
red = pulseIn(OUT,LOW,10000);
greenFilter();
green = pulseIn(OUT,LOW,10000);
blueFilter();
blue = pulseIn(OUT,LOW,10000);
TCS3200_off();
}
void TCS3200_on() {
digitalWrite(LED, HIGH);
digitalWrite(S0, HIGH);
digitalWrite(S1, HIGH);
delay(5);
}
void TCS3200_off() {
digitalWrite(LED, LOW);
digitalWrite(S0, LOW);
digitalWrite(S1, LOW);
}
void noFilter() {
digitalWrite(S2, HIGH);
digitalWrite(S3, LOW);
delay(5);
}
void redFilter() {
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
delay(5);
}
void greenFilter() {
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
delay(5);
}
void blueFilter() {
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
delay(5);
}
// LED, S0, S1, S2, S3 are OUTPUT, and OUT is INPUT
I'm performing these measurements in a decently lit room...sometimes covering the sensor, sometimes not. I'm also pointing the sensor at various objects....with the above values (2,4,4,3) measured from pointing the uncovered sensor at a generally-white piece of paper.
Just to clarify...this sensor is part of a larger Arduino project. Along with the interrupt system I have for capturing a particular RGB space, I have a temperature sensor LM25, a motor control interrupt with encoder, and a constantly updating LCD display stacked together. So 4 separate entities occurring at once.
The measurements from above, however, were still captured before initialization of the other entities even occurred. The TCS3200 is the first thing for the Arduino to handle.
If this is the correct way to go about doing this, then I'm stumped. I have a bunch of other code involving what happens after the frequency capture (based on k-nearest approximations).
-thanks, Anthony