# Designing around Output pin limitations

I'm new to Arduino and am working on a project with my son. We are using the LillyPad USB board (schematic) to drive a bunch of LEDs (LED Datasheet). Our project is based loosely off of the 'Turn Signal Biking Jacket'.

Our project calls for 7-11 LEDs in parallel on a single circuit. In the 'Turn Signal' project the LEDs are driven off of a pair of output pins (1 HIGH and 1 LOW). In a circuit that looks like this... simulate this circuit – Schematic created using CircuitLab

Is this ideal? Would it make more sense to connect the LED-chain to Vcc and have the return line connected to a single output set to LOW (to turn on the lights)?

If we were to have 3-4 of these LED-chains on at once, do I have to be concerned with total draw on the microcontroller?

Help? Thoughts?

• Why are you using 2 digital pins for 1 output? Instead of writing LOW to one pin, you can wire the leds to GND directly, so that the current doesn't have to flow back into your digital pin hardware and you are saving an extra pin. (In his answer Majenko also wires them to GND) – chrisl Feb 26 '18 at 16:01
• @chrisl That was my thought as well. That's how it is drawn up in the original 'Turn Signal' project. – Tony Feb 26 '18 at 20:34

If you know the forward voltage of the LEDs you can easily do some calculations.

For a typical red LED the forward voltage is around 2V. Other colours vary. So we can work out that, at 5V supply, each LED with its own 150R resistor, would take:

``````     V    5-2
I = --- = --- = 20mA
R    150
``````

With 11 LEDs in parallel on at once that would be 0.02 * 11 = 220mA.

That is far more than the 25mA an IO pin is able to supply, so you will damage the Arduino doing it like that.

Instead you will need to switch each chain of LEDs with a transistor of some form. I'd choose a logic-level N-channel MOSFET as a "low-side" switch: simulate this circuit – Schematic created using CircuitLab

Now your Arduino doesn't care about the current - all it sees is the MOSFET.

If your LED forward voltages are less than 2.5V you can also chain them together to halve the current: simulate this circuit

Since the forward voltage is now double you use a smaller resistance to set the current (R=V/I, where V is 5-2Vf).

• if I'm reading the datasheet correct, the forward voltage is 'typically' 3.3v 'max' 4.0v. I'll add a link to my Question. Also, Vbattery should be 3.7V as that's the output from the Lithium Battery. And, I think, Vcc is 3.3v (I'll update the question with the datasheets) – Tony Feb 26 '18 at 20:43
• So you won't be able to double them up then. – Majenko Feb 26 '18 at 20:44
• Using your math with the updated datasheet info (Vbatt = 3.7V, Vf = 3.3v), I get 3.7-3.3/150 = 3.33mA per LED. Or 37mA for 11. That is still more than the 25mA per pin. How does the ~120Ohms of thread resistance figure in? That would lower the voltage (slightly) and thus the voltage drop across the LED, right? – Tony Feb 26 '18 at 21:20
• Yep. you would probably just get away with 11 LEDs. The absolute max for a Io pin is 40mA. – Majenko Feb 26 '18 at 21:21
• And if we keep the LED count to 9 we'd have a bit more room. Thanks. – Tony Feb 26 '18 at 21:23