Ping sensor and LED lightbox

kato:
The below code works which I will have to use for the exhibition has to installed for Tuesdy.
As you approach the light box the LEDs get brighter.

  cm = constrain(cm,20,100);

i = map(cm,20,100,225,0);                                   // map "i" 20 to 0 and 100 to 225 and assign it varialble "i"
  analogWrite(LED,i);

That works if you want people to be able to control the brightness by how close they get. If you want the original effect:

  if(cm <= 100)
  {
    if (brightness < 255)
        brightness++;
  }
  else
  {
    if (brightness > 0)
        brightness--;
  }
  analogWrite(LED,brightness);
  delay(10);