Connecting an LED directly to a power source without a current-limiting resistor is a guaranteed way to permanently damage it. LEDs are current-driven devices with a specific forward voltage drop ($V_f$), and any excess voltage from your power supply ($V_s$) must be safely absorbed by a series resistor.
The Calculation
To find the exact resistor value ($R$) needed to protect your LED, we use Ohm's Law. We take the source voltage, subtract the LED's forward voltage, and divide by the desired forward current ($I_f$), which is typically around 20mA for standard LEDs.
$$R = \frac{V_s - V_f}{I_f}$$
Use the interactive tool below to calculate your required resistance and check the power dissipation to ensure your resistor won't overheat.
``