Hi!!! I'm writing because I'm experiencing some trouble with my arduino code. In the specific I need to normalize to the clear the data received from the TCS34725 sensor and I have to say that the data from the sensor are of 16 bit so that their range is 0-65535.
To normalize the data to clear I have to apply the following formula:
factor = 255 / clear value
Normalized value of red, green blue = value from sensor * factor.
Now, the result of factor is a 0 followed by a comma and the numbers, but is recognized as 0 so that the values of red, green and blue are 0!!
For example I receive the following data from the sensor:
red = 226
green= 381
blue= 451
clear= 1058
so that I have for red:
factor = 255/1058 = 0,2410
red = 226 * 0.2410
but I have just 0 for the values of red, green, blue as the factor would be 0.
the part of my arduino code to do that is :
float factor = 255 / c; /* Factor of Normalization */
float rc = r*factor; /* value of red normalized to the clear */
int redc = round(rc); /* Normalized value of red rounded to the nearest integer */
float gc = g*factor; /* value of green normalized to the clear */
int greenc = round(gc); /* Normalized value of green rounded to the nearest integer */
float bc = b*factor; /*value of blue normalized to the clear */
int bluec = round(bc); /* Normalized value of blue rounded to the nearest integer */
and before I've declared the variable in the following way:
float factor;
float rc;
float gc;
float bc;
int redc;
int greenc;
int bluec;
What I have to do in order to obtain a number different from zero for the variable factor? How Do I have to declare the variables?`
Really thanks for your help!!