Ultrasonic sensor with LED, how can I do this?

If your sketch is working, what more did you hope to achieve? Seems good for a beginning coder!

If I might suggest, read up on how to segment your code into Functions. It will help readability and debugging. Check out a basic tutorial here.

In the sample code I gave you (above), you will see how I suggested you might move your code into Functions. With them, most of the details are abstracted from the main Loop code, making that much easier to understand.

Best of luck!