Quick tip: Calculating LED Resistor Values
From a question someone posted in Discord.
what's a safe bet on how many ohms resistors for 2-pin leds should be
This is the basic circuit for an LED, right? LEDs are simply diodes. Diodes are non-linear circuit elements that have a decently high resistance until they reach their Vf or forward voltage. Once they reach their forward voltage (between 1-2V for typical LEDs you will encounter and a key piece of info to find from the datasheet) they lose nearly all resistance and you can treat the circuit as the following:
The LED is actually just another battery with voltage Vf, but opposing the voltage V of your system.
Do some ohm's law stuff. I1 = (V-Vf)/R1.
If you want your current through the LED to be something like 5-10mA, just set I1 to 5*10^-3 and solve for R1
Another thing to keep in mind is the power through the resistor. It's a good check to P = R*I^2 to verify that the power rating for the resistor is high enough and it won't get super hot.
In practice, look at the datasheet and use this calculator: https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-led-series-resistor
Here is a quick example with a random LED.
Max current, If, of 30mA. I will use 5mA here.
Typical Vf of 2.0V.
Into the calculator, we get 260 ohms with a power use of 6.5mW. Looking up the closest resistor value, I would recommend 270 ohms.
Thanks!