I’m not sure how many resistors I need for my LilyTiny project. I’m going to have 8 x 5mm LEDs in my circuit with one LilyTiny and a coin cell battery. Each connection in the LilyTiny (0-3) will have 2 LEDs attached. Can someone please tell me how many resistors I need and whether 330 Ohms is the correct resistance. Thanks
Sounds like a fun project underway! In the perfect world, you would use a bit of ohms law to calculate resistor values. With that said, you are using a CR2032 coin cell battery which are usually rated for 80-150mA peak current because of their internal resistance.
Typical LEDs are rated for up to 20mA, which gives you some buffer if you have a couple of LEDs connected in parallel to the CR2032. So you will be fine using them directly, no resistors. Bear in mind LEDs are polarity sensitive, they’ll only work in one direction.
Some other info for your project:
If you feel the need to use a resistor for your project, then 47ohms would be fine for red LEDs with a CR2032. If you are using blue/green then start with 47ohm and go down to 10ohm if they do not turn on. Use one resistor for each group of colors, there is no way you will hit the resistors rated power limit in this circuit.
To be overly safe, use a multimeter to measure the peak current of a CR2032 (as they vary between manufacturers). Use the 10amp setting, and watch what happens as the current goes from peak to settled rate over 20-30 seconds. I just did this with one of ours, it went from 220mA to 70mA and stayed there. I have no reservations connecting 5+ LEDs in parallel to that battery directly, let alone through a LilyTiny and wires (which all have their own resistances). It’s not perfect, but the LEDs will survive. Even a single LED connected directly to the CR2032 would be fine, this is backed by the ever-so-popular project called “LED Throwie”
Red LEDs need about 2 volts to operate, blue+green+white need 3.2+V. You may find that Red LEDs are better to use with CR2032s over the life of the battery.
At the end of the day. LEDs are usually rated for 20mA, but they need just a trickle of energy to visibly turn on (1-3mA). LED brightness has a non-linear curve, after about 5mA the brightness changes are almost not perceivable / not useful for most projects. Experimenting with resistors to get the LED within the “just on” range will increase how long the battery can power your project.