Directly driving an LED from a microcontroller's IO pin with no resistor is not usually a good idea. However, there are caveats:
- The IO pin has a maximum current it can source. That limits what the LED can get
- Draw too much current from the IO pin and it overheats and burns out
- Allow too much current through the LED and it overheats and burns out
The ATMega chips usually have a maximum of 40mA per pin, with a recommended maximum of no more than 25mA. A typical LED has a steady-state current of around 20mA. But, LEDs also often have a rated pulse current limit.
For instance, a cheap 3mm red LED has a maximum forward current of 30mA and a pulse current of 100mA at a 10% duty cycle limit, and an on-time of less than 100µs.
So by pulsing the LED at a higher current (say 40mA), as long as you are within a 10% duty cycle, and the pulses are less than 0.1ms long (which means a PWM frequency [50% duty] of no less than 1000Hz) would be well within the specifications of the LED.
What effect would it have on the IO pin? Well, over time the current draw would be around a tenth of the peak, since it's only on for a tenth of the time. However, that doesn't mean that it dissipates a tenth of the power. Most power is dissipated during switching, and with all that extra switching going on it's going to be dissipating much more power. That may, or may not, depending on how the pin is constructed, negate the benefits of the pulsing.
Either way, it is still good practice to include a small resistance. Not to protect the LED, but to protect the IO pin. Just enough to keep the current below the absolute maximum for the IO pin.
I didn't notice you are using a BJT. The above still applies though, but with slight differences:
- You should use a resistor to limit the current to the pulse current limit for the LED, or
- You should use the BJT to set the current by controlling the current in from the IO pin that controls it.