TCS34725 RGB LED balance stabilizer

Hi! I'm Thomas. I have been working on film scanning light which now using RGB LED for backlight.

But I have to balance light that so when shine through the film mask it will look white (film mask is orange) Which need to be adjusted on every film being scan.

I came across TCS34725 sensor and the datasheet also mentioned about ability to stabilized RGB Backlight.

I need help on coding which I don't find any sample to learn through.

I want it to read the initial RGB light shine through the film mask and then adjust automatically so that the light passthrough orange mask stabilize to white as sensor calibrate RGB balance.

I using it on ESP32 with i2C for TCS34725 and LEDC PWM function for RGB control.

Thanks!!!!

Basically: read the RGB sensor, correct LED brightness based on those readings: i.e. if say the red reading is higher than the green and blue, decrease the PWM value for the red light accordingly. Do this until all balanced.

You may maximise overall background light brightness by setting the weakest colour of the three to PWM value 255 and then adjust the other two down until all give the same reading of the sensor.

So I may adapt PID function for this, it should work right?

Why PID?

Don't you need to find a single setting and stick to that for the rest of the slides of that film?

Ahh okay i get the point.