Color Sensing with TCS3200, Need Help with Code & Understanding

I have no idea of what the frequencies mean. But B= -153 is just plain wrong. The analogWrite() writes values from 0 to 255. That's one unsigned byte. Whatever you put there will be treated as an unsigned byte. -153 is a signed number that needs more than 8 bits. Passing it to the analogWrite() will just pass 8 bits. The value passed is 01100111 or 103. Doing writeAnalog(-153) will equal analogWrite(103).

If frequency 25 means full blue colour and frequency 70 means zero blue colour, then your original mapping function is correct. But do as I told you to. If the map function returns values outside the 0 - 255 range, you must adjust the value to 0 or 255. Why it goes beyond the range is beyond me. Instead of adjusting to the range, perhaps you could re-read the sensor until you get sane values.