range finder and LEDs

Sorry, to be clear

If you had been, I wouldn't have had to ask. :slight_smile:

Look at the blink without delay example. The example shows how to turn an LED on or off at specific times. What you want to do is to create a new brightness value each time the LED should change state. Keep in mind that the brightness value does not continue increasing forever. Instead, once it reaches some limit values, the amount of change changes sign.

When an object is in range, do one thing. When it is not, do something else.