Corrolation between Distance and RGB value

That key part would be expressing the question clearly.
What do you mean ‘increase by 5’ ?
What sensor?

Then toss some of your pseudo-code so we might understand more.
And a schematic/block diagram (not Fritzy)