Up to this point, we’ve focused on the mechanics of electronics — wiring and soldering — skirting around the theory by following some shortcuts and recipes. It’s sufficient for many folks’ needs.
Learning the underlying principles creates opportunities for using other battery types (including rechargeables) and achieving longer run times. Or maybe you’re just curious! There’s some reading, new terms and a little bit of math involved, but nothing onerous.
Electricity is the transfer of electrons — negatively charged particles in every atom. It’s an invisible force of nature, but we can picture it like water. As electricity flows from place to place, things can be inserted in that flow to extract useful work, just as a water wheel uses a flowing stream to mill grain. Electronics, then, is creative plumbing.
A battery houses two complimentary chemical reactions; one producing a surplus of electrons, the other a deficit. The two reactions are kept apart within the battery, but the attraction is strong enough that adding an external conductor — a path for electrons — consummates those reactions. This is why batteries have a “+” and a “–” end, and why electronics is all about circuits — a loop between the two. When that loop is closed, electrons flow, things happen. (This is what a switch does — it opens or closes the circuit.)
Different battery chemistries use different combinations of reactions. That mix determines the Voltage, sort of the “urgency” of the reaction. Using our plumbing analogy, Voltage is like water pressure.
Our standard recipe called for three AAA or AA alkaline (single-use disposable) batteries. The chemistry of these batteries produces about 1.5 Volts. Linked end-to-end in the case (“in series” in electronics jargon), voltages are added to get a total: 1.5 + 1.5 + 1.5 = 4.5 Volts. Our recipe was built around this number; it’s why there’s a simple choice of two resistors depending on LED color. Change that, and something else has to change with it.
(In electronics, the technical term for a single battery is a cell. “Battery” then refers to a group of cells. Going forward, we’ll use these terms.)
The chemistry of rechargeable Nickel Cadmium (NiCd) or Nickel Metal Hydride (NiMH) cells produces about 1.2 Volts each. Lithium Ion or Lithium Polymer cells are 3.7 to 4.2 Volts (depending on the exact chemistry used). The battery packs for cordless tools and radio-control vehicles often link a number of cells in series for higher voltages. And inside a 9V alkaline battery there’s really several small 1.5V cells in series. We can work with any of these with a little more knowledge…
Current is a head count of the flow of electrons, in units called Amperes (A). One Ampere = 6.2 quintillion electrons passing a given point in one second!
What regulates current? In plumbing, the width of the pipe. In electronics, it’s resistance, measured in Ohms (Ω). As alluded to in our recipe, resistance in a circuit is a throttle on the cells’ chemical reaction, keeping it from going off too quickly.
Voltage, current and resistance are directly interrelated; knowing any two of those values, the third can be derived. This relationship is called Ohm’s Law:
V = IR
Voltage (Volts) = Current (Amperes) × Resistance (Ohms). (“I” is from the French word intensité…C was already taken.) Or, through algebraic substitution:
R = V÷I (Resistance = Voltage ÷ Current)
I = V÷R (Current = Voltage ÷ Resistance)
This relationship is the bedrock of all electronics, as fundamental as F=ma in physics.
LEDs trade electrons for photons — light! And just as batteries have different chemistries and voltages, LEDs too have a unique forward voltage (abbreviated VF) at which they operate, a function of their chemical composition.
Typical Forward Voltage (VF)
Green (older yellow-green variety)
Blue, white, ultraviolet and newer “true” green
These numbers are just rough guidelines, they’ll do for most situations. For more precise values, and for other colors not listed here, the exact voltage can be found on the package, product page or in the datasheet (documents published by electronic parts manufacturers listing every minute detail of a device). Here’s the back of of turquoise LED package:
There’s the number we’re after, VF: 3.2 Volts.
That next value — IF — will also be useful in a moment. Remember “I” represents current in our equations. IF is forward current.
Current determines the brightness of an LED…up to a point. Too much current will destroy it!
The LED above shows a maximum current of 20 milliamps (1mA = 0.001 Amperes, so 20mA = 0.020A). This value is typical of most LEDs, but some work higher or lower…again, check the packaging, product page or datasheet.
Notice that’s a maximum. I like to back off a little, 10–15%, to ensure longer life. So that’s 17–18 mA.
The LED voltage (let’s call it VLED instead) must be lower than the battery voltage (VBAT), or it won’t light. Taking the difference of the two voltages then, and applying Ohm’s Law, tells us exactly how much resistance is needed in that gap to produce the desired current:
R = (VBAT – VLED) ÷ I
Assuming a 4.5V battery from the recipe, and a 3.3V blue LED, aiming for 18mA current:
R = (4.5 – 3.3) ÷ 0.018 = 66.67 Ohms
But resistors generally come in a limited set of values, so we round up to the next common size…68 Ohms (as shown in the recipe), or perhaps 100 Ohms if that’s all you can find.
How about a 3.7V lithium-polymer battery and a 2 Volt red LED?
R = (3.7 - 2.0) ÷ 0.018 = 94.44 Ohms
Step up to the nearest standard size, 100Ω. And that’s all there is to it! Nobody can give you crap for not doing “real electronics” anymore.
Resistors are easy when they’re labeled on the package. Not so much once they’re jumbled with other parts. Resistor color charts like this one help in deciphering the codes.
Recall that batteries in series produce a higher supply voltage. LEDs connected in series likewise have a higher forward voltage.
If your design uses multiple LEDs, and if the battery and LED voltages allow it, connecting in series like this is slightly more efficient, helping the battery run longer.
LEDs in series (like above) can share one resistor for the chain. LEDs in parallel (as originally shown in the recipe) require separate resistors for each, even if the LEDs are the same kind. A combination of these — a series-parallel circuit — has one resistor per string. This combines everything learned so far, and it’s an opportunity to practice the math:
LEDs and the associated formulas are explained in even greater depth in our All About LEDs tutorial. This includes quizzes to make sure you’re on the right track.
Practicing a few times manually helps to reinforce the concepts. When you just need quick answers, there are LED resistor calculators online, and an excellent one included in Adafruit's Circuit Playground app for iOS:
If the supply and forward voltages are very close, you might get a resistor value near zero. As insurance, always include at least a little resistance — perhaps 50 Ohms — to allow for differences between “typical” and actual voltages. For example, a fresh battery has a slightly higher voltage than one nearly depleted.
If using a battery or case without its own switch, consider adding one of these Tactile On/Off Switches with Leads. The positive clicky action and low profile make this one great for wearable projects.
Coin cells exhibit internal resistance — they can only push so much current, it’s the inherent nature of their size and chemistry.
So yes, they can run an LED directly…but…this puts stress on the cell and shortens the run time. You can get away with it for quick results, but doing the math and adding a resistor improves longevity.