There is more to it than just some code. The LED is a current operated device, and will burn up (and quite possibly take your serial port with it) if current through the LED is not properly controlled.

You have no indication about how you are planning to attach the LED to the port, so worrying about code fragments is getting ahead of yourself.

You also need to find what voltages are present out of the COM port, so you can arrange for a properly-sized resistor to control current in the LED. Then you can see about generating code to control the LED with PWM.

You're going to need a current limiting resistor for the LED. A 2.2k LED limiting resistor should be a fair ballpark value for a start. Your code needs help though. As it currently stands, your code will throw as many design time and run time errors as you have lines of code! You may also want to consider utilizing the DTR pin instead of the TX pin, as the code to do this will be easier.