Color Sensing with TCS3200, Need Help with Code & Understanding

Johan_Ha:
Not the frequency! The frequency doesn't get negative, does it? Have a look at this:

bcolor = map(frequency, 25,70,255,0);

If frequency is below 25, bcolor goes over 255. If frequency goes over 70, bcolor becomes negative. Don't mind what frequency is. Check only bcolor and set it to 0 or 255 if it went over the boundaries.

Ah, so I don't need an If statement? Just need to adjust the numbers in the "map", and calibrate it to my setup?

I see that map() uses the syntax of: map(value, fromLow, fromHigh, toLow, toHigh)

I'm not sure how to change this. I tried changing it to (frequency, 25,70,0,255) for fun. The comments in the code say the RGB range (" //Remaping the value of the frequency to the RGB Model of 0 to 255") is 0 to 255. So I reckon the results in terminal should be within the bounds of 0 to 255 then too.

I'm worried that it's not working 100% correct, as I see numbers below 0.

For example when scanning a yellow paper, the LED does show up yellow.

But the terminal shows:

R= 158 G= 60 B= -153

This is right, as Yellow is a mix of Red and Green, however, blue is set to a negative number. Do you think that's OK? Or should the code be altered to make blue (or any other negative value) be set to 0?

Is it possible that negative values may be being sent to the LED, and have an harmful effect on the output?