3

I'm totally new to Arduino, and microcontrollers for that matter, so I'm having a hard time figuring out how to connect LEDs to multiple pins, but using a common external power supply...

I've created a starting light that's connected to pin A0-A4 + A5 (turn all LEDs on). I hooked each LED to its own pin directly (A0-A4) for the countdown part ("5, 4, 3, 2, 1, ..."), and then 5 additional LEDs to pin A5 ("GO!").

For the countdown part, when only one LED is on at a time, there's enough power. But if I were to light them all up at the same time, there won't be. So I figured that I should put a relay into the mix for that part, and have them draw power from an external 12 V power supply.

I did manage to make the relay work in the circuit - switching all LEDs on/off, and getting power from the external power supply, but only through one pin.

I'm not sure how to have the start lights use an external power supply, and at the same time get signals from multiple pins. How do I do that?

I'm sorry if my description is unclear. So please let me know if you need more information.

  • The LEDs are 3.4 V 20 mA.
  • The power supply I'm planning to use is 12 V.

I'm planning to have this start light - which is built in its own casing - use its own power supply, while the Arduino is running of the power from USB. So all I want to do, is to have the signals sent over to this starting light unit, and not power and ground.

UPDATE:

Here's a quick overview of how I'm testing this whole thing at the moment:

Friting diagram of Arduino and LEDs

The 5 red countdown LEDs (red) is getting powered by the board itself through the pins, while the 5 "GO!" LEDs (green) are getting powered from a 12 V power supply since they're all are going to be turned on simultaneously.

My question is how I can get both the 5 red LEDs, that uses separate pins, to get powered from the external power supply as well?

Since all the LEDs are built in its own casing, apart from the microcontroller because that also handles other stuff...

Did that make any more sense at all?

8
  • 1
    You don't need a 12V supply for the LEDs. You probably don't need a separate supply at all. All you need is to switch the LEDs externally. Commented Nov 18, 2014 at 2:15
  • Could you please show your circuit? In particular, it is important to see if you use resistors in series with eache LED.
    – jfpoilpret
    Commented Nov 18, 2014 at 5:32
  • 1
    In general you don't really need 20mA current to light your LEDs, typically limiting the current to 10mA or even less will be OK. If you need 5 LEDs in parallel though, you'll probably need a transistor. Forget about relays, that's probably the most awkward way to switch LEDs!
    – jfpoilpret
    Commented Nov 18, 2014 at 6:25
  • Added some more details now
    – ThomasK
    Commented Nov 18, 2014 at 15:38
  • No that doesn't :))) The relay part is totally incorrect :)
    – Martynas
    Commented Nov 19, 2014 at 13:33

3 Answers 3

3

Caveat: I too am new to this. The answer below is my understanding and I need an expert to confirm.

Current in your Arduino:

  • A single digital pin on a Uno will provide 40mA -- and could conceivably power two of your LEDs.
  • The VCC pin outputs 200mA and could therefore conceivably power ten.

So all you need to do is power your LEDs from your VCC, but use your digital pin as a switch. One idea, which you had, was to use a relay. But a relay is an inductor so don't connect it directly to the Arduino. Make sure it's on a shield. But that shield will essentially do exactly what you need to do, but to drive the relay rather than drive your LEDs: It will use the digital pin to switch the VCC and activate the relay.

Luckily this isn't hard. All you need is the most magical of all components: the transistor. A transistor can be used as a switch to turn on a higher current. In your case, the transistor can switch the VCC connection to the LED array when the digital pin is high.

Here's the circuit I believe you need based on my understanding. Note that the values of the resistors and transistors are just made up. Read the docs above to get the correct values.

Power five LEDs from one digital pin

5
  • Experts: if any of this is wrong, please help me learn! I'm happy to admit that this is just my understanding and it shouldn't be relied upon. But if I'm not trying to understand, I'll never learn :D Commented Nov 18, 2014 at 5:59
  • Very nice direction, and IMO transistors are the way to go here. Just not sure that the circuit fills OP's requirements to turn each led separately.
    – Omer
    Commented Nov 18, 2014 at 7:34
  • @Omer this is only for the 5 green leds. The 5 red leds can remain connected, directly to pins A0-A4
    – Gerben
    Commented Nov 18, 2014 at 16:32
  • 1
    I've updated my answer. What I'm trying to accomplish is to have all the LEDs, both red and green, draw power from the external powersupply. That way, I would be able to just send the signals to the starting light, and not the power aswell... But thanks for great links and such.
    – ThomasK
    Commented Nov 18, 2014 at 18:56
  • @ThomasK: my point is you don't need an external power supply. But if you really really want to there's nothing stopping you. The transistor can switch an external source just the same way. Read the links. Commented Nov 18, 2014 at 19:50
3

I think one of the best way for you would be to use 74HC595 chip. You will learn a lot while developing board with this chip. It is well documented Serial to Parallel Shifting-Out with a 74HC595. Using 3 pins you will be able to turn on & off as many LED's as you wish, use external power supply and so on.

Also there is MAX7219 chip. The MAX7219 and MAX7221 Led drivers. And there are a lot more ways to do this.

1

If you really want an external power supply, you can use ULN2003 / ULN2803, which are 7/8 darlington 500 mA each transistor

1
  • If he wanted the LEDs to sequence as 1, 2, 3, 4, 5, 1+2+3+4+5 then I'd totally go with a darlington chip so you can control them all individually plus any combination. But as he wants 1, 2, 3, 4, 5, 6+7+8+9+10 it's only the 6-10 (which are group controlled) that need the higher current. I reckon a chip is overkill when it can be done with one transistor (or two in a darlington configuration, plus a diode if I'm remembering right) Commented Nov 19, 2014 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.