When several LEDs must light at once the IO pin runs out of current, so a transistor expands the drive. This page shows how to calculate the LED current-limiting resistor and where to place it in a transistor driver.
An LED is a current device with a forward drop of about 1.8 to 3.2V and brightness set by current. Without a series resistor the current runs away and the LED dies. The limit resistor is R equals V_CC minus U_F over I. Indicators use 5 to 15mA, bright types up to 20mA. In a transistor driver the resistor still sits in the LED branch and limits LED current, not base current.
For an NPN driving one LED, put the LED and its resistor in the collector to V_CC, emitter to ground, base through R_B to the IO. At 5V with a 2.0V red LED and 10mA target, R is 300ohm, use 330. R_B follows I_C over beta; at beta 100, I_B is 0.1mA so R_B about 43kohm, use 22kohm for margin. Parallel LEDs each need their own resistor, never one shared.
Brightness rises with current but from 10mA to 20mA the gain is small while heat doubles. Five to eight milliamps is enough for an indicator. A common fault is sharing one resistor across LEDs whose forward drops differ, so the lowest drop one hogs current and fails first.
| LED colour | U_F | Resistor at 5V 10mA |
|---|---|---|
| Red | 1.8 to 2.0 V | 330 ohm |
| Yellow | 2.0 to 2.2 V | 300 ohm |
| Green | 2.0 to 2.4 V | 270 ohm |
| Blue | 3.0 to 3.4 V | 180 ohm |
| White | 3.0 to 3.4 V | 180 ohm |
| Current | 5 to 20 mA | over 20mA shortens life |
LED driving fits panel indicators, status lights and segment drives. Confirm the colour and rated current, pick the standard resistor, and give each LED its own limiter. Blue and white have high drop, so at 5V the margin is thin and a 12V bus with local drop is better.
The quantities and component characteristics discussed here follow current national standards and the corresponding IEC documents: Device application and symbols per GB/T 4728; safety IEC 60204-1. Always check the device datasheet and the product design file for ratings and derating.
Locate the issue with the approach above, then confirm with measurements; safety-related circuits must follow the standards and manufacturer requirements.