To power an LED, the current that flows through it needs to be limited. For simple LEDs like the ones for signalling purposes, the cheapest and easiest way is to use a resistor in series with the LED, to limit the current. The question that normally remains is: Which value should the resistor have?
First of all, you need to know at which voltage you want or need to run your LEDs. Most electronic circuits use some kind of standard voltages, like 3.3 V, 5 V or 12 V. Also very important is the forward voltage (U_f) of the LED (or LEDs) you want to power. The forward voltage is the voltage the LED needs to light up at all. It’s also the voltage that drops by passing through the LED. This voltage can be measured i.e. by using the AVR Transistortester or a multimeter (it depends on the voltage the multimeter uses). Another way to find the forward voltage is to check out the datasheet. Or you could just use some kind of default value, determined by using the color of the LED as indicator.
The second important value, is the maximum current (or forward current) the LED in question can handle without being damaged. Usually it’s about up to 20 mA (0.02 A). But in reality, most of the time, you don’t want to run the LED at its current limit. In moste situations, the light is still more than bright enough at 5 mA (or even less) to do it’s job perfectly fine. If you’re not sure, test it on a breadboard or with some alligator clips and different resistor values.
For the calculation of the resistance value of the resistor, you need the exact voltage at the resistor. Normally this would be the voltage from your power supply. But since the LED is also a part of the circuit, it will reduce the voltage. Therefore, the forward voltage of the LED needs to be subtracted from the supply voltage first. The resulting voltage value will then be divided by the current in Ampere.
Now the same, using some example values:
Usually the next higher value, which is available, will be used. Like in the first example maybe a 680 Ohm resistor and in the second example 4700 Ohm.
But what about the power? Will the usual 1/4 Watt resistor handle the current? How much current will pass through the resistor at 680 Ohm?
As you can see, the resistor can easily handle that, even at 24 Volt.