First is, where did he place the photoresistor and how it placed with the RGB inside that 'cover' ?
Well you can't see it at all can you?
It looks like he might be using the LED as a photo sensor, there is no photo resistor in that circuit. Unless it is that pot with the arrow pointing in the wrong direction.
However I agree with you it is quite a piece of crap to put out on the internet.
The code looks like something has mangled it and changed the < symbol to '<' this is it corrected.
// Color Match
// January 28, 2012
// by George Gardner
int pwmrgb[] = {11, 9, 10}; //sets the r,g,b cathode pins for the pwm led (must be pwm pins)
int rgbbias[] = {100, 15, 0}; //sets the bias for the illuminated RGB LED: higher number = less intense (max 255)
int rgbds[] = {255, 255, 255};
int maxwhite[] = {773, 624, 542};
int minblack[] = {309, 134, 104};
int sensorValue = 0;
int speed = 5;
void setup(){
pinMode(2, OUTPUT); //sensor red cathode
pinMode(3, OUTPUT); //sensor green cathode
pinMode(4, OUTPUT); //sensor blue cathode
Serial.begin(9600);
for(int i = 2; i< 5; i++) {
digitalWrite(i, HIGH);
analogWrite(pwmrgb[i-2],
rgbds[i-2]);
}
}
void loop(){
int switchstate = analogRead(A5);
if(switchstate > 1000){
for(int i = 2; i < 5; i++){
digitalWrite(i, HIGH);
analogWrite(pwmrgb[i-2], 255);
}
delay(1000);
switchstate = analogRead(A5);
while(switchstate < 1000){
switchstate = analogRead(A5);
}
delay(500);
}
for(int i = 0; i< 3; i++){
delay(100);
digitalWrite(i + 2, LOW);
delay(100);
sensorValue = analogRead(A0);
rgbds[i] = constrain(sensorValue, minblack[i], maxwhite[i]);
rgbds[i] = map(rgbds[i], minblack[i], maxwhite[i], 0, 255);
printresults(i);
rgbds[i] = (255 + rgbbias[i]) - rgbds[i];
rgbds[i] = constrain(rgbds[i], 0, 255);
digitalWrite(i + 2, HIGH);
}
for(int i = 0; i< 3; i++){
analogWrite(pwmrgb[i], rgbds[i]);
}
delay(speed);
}
void printresults(int i){
if(i == 0) Serial.print("RED: ");
if(i == 1) Serial.print("GREEN: ");
if(i == 2) Serial.print("BLUE: ");
Serial.println(rgbds[i]);
}
However that page is so poor I would look for a better one, it is quite a simple concept.