So: if(..........<40) activate led.
Yes, if ..... is the value read from the ping sensor (and 40 is reasonable).