What I want to achieve is that between 10 and 60 cm of my HCSR04 sensor the color fades from red to blue on my RGB LED in steps of 1 cm between 10 and 60 cm.
I have tried creating some own functions which calculate how much the analogWrite has to change every cm. Yet have had no succes..
I want to implement this function in the following code:
I hope my question is understandable...