How to connect multiple LEDs (and colours) in Series

Hi all, you helped me with some code recently, which seems to be working and fine. I have now started to construct my project. I am using all of the ports basically, and then running 2 -15 led 0402 from each port (a mix of White, Red, Green and Yellow). I started soldering Greens and Reds together to run them in Series to one port, but the greens were not lighting up.

Is the best solution to include mosfet buffers for the ports that go over the limit?

The code works fine, but any points would be happy to receive them.

int ledPin9 = 9;
int ledPin8 = 8;
int ledPin7 = 7;
int ledPin6 = 6;
int ledPin5 = 5;
int ledPin4 = 4;
int ledPin3 = 3;
int ledPin2 = 2;
int ledPin10 = 10;
int ledPin11 = 11;
int ledPin12 = 12;
int ledPin13 = 13;
int ledPinA0 = 14;
int ledPinA1 = 15;
int ledPinA2 = 16;
int ledPinA3 = 17;
int ledPinA4 = 18;
int ledPinA5 = 19;




/*
1  East Cardinal 	Fl(3) W 10s
2  South Cardinal 	Fl(6+1) W 10s
3  West Cardinal 	Fl(9) W 10s
4  North Cardinal 	Q
5  					Fl(2) R 5s
6  1/3 RACING		Fl R 5s			
7  					Fl(4) R 10s
8					Fl(2) R 10s
9  1/3 RACING		Fl(1) R 4s
10 1/3 racing + BW	Fl(1) R 3s
11 					Fl(4) R 15s
12 					Iso R 2s
14					L.FL 10s
15					FL(1) R 10
16					FL (3) G 7s
17 Lighthouse		LH 4s FL. 10s
18
19
*/
byte ledSequ [][18] {
///1  2  3  4  5  6  7  8  9  10 11 12 14 15 16 17 18 19
  {0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1},
  {1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0},
  {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1},
  {1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0},
  {0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0},
  {1, 0, 1, 0, 0, 0,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] {ledPin13, ledPin12, ledPin11, ledPin10, ledPin9, ledPin8, ledPin7, ledPin6, ledPin5, ledPin4, ledPin3, ledPin2, ledPinA0, ledPinA1, ledPinA2, ledPinA3, ledPinA4, ledPinA5};
void setup()
{
  Serial.begin(9600);
  pinMode(ledPin13, OUTPUT);
  pinMode(ledPin12, OUTPUT);
  pinMode(ledPin11, OUTPUT);
  pinMode(ledPin10, OUTPUT);
  pinMode(ledPin9, OUTPUT);
  pinMode(ledPin8, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPinA0, OUTPUT);
  pinMode(ledPinA1, OUTPUT);
  pinMode(ledPinA2, OUTPUT);
  pinMode(ledPinA3, OUTPUT);
  pinMode(ledPinA4, OUTPUT);
  pinMode(ledPinA5, OUTPUT);
  
}
void loop() {
  const unsigned long blink = 750;
  static unsigned long blinkMillis;
  if (millis() - blinkMillis >= blink ) {
    static int nummer;
    blinkMillis = millis();
    Serial.println("blink");
    for (unsigned int n=0; n<sizeof(leds); n++) digitalWrite(leds[n],ledSequ[nummer][n]);
    nummer++;
    nummer = nummer % (sizeof(ledSequ)/sizeof(leds)); 
  }
}

If LEDs are wired in series you need more that the sum of the LED forward voltages to supply them. If you have 2 green LEDs in series and each of their Vf is 3V you need over 6V to get them to light. Also a current limit resistor, of course.

That also means that a transistor would be needed to switch the higher voltage.

1 Like

As @groundFungus said, when you connect LEDs (or, in fact, anything) in series, their voltage drops add.

Red LEDs have a lower forward voltage than green - so you probably had just enough voltage to light the red ones, and not (quite) enough for the greens.

Here's a table of typical forward voltages for different LED colours:

So a red LED might have a forward voltage of 1.7V - so a 5V Arduino could power two of them:
2 x 1.7V = 3.4V
You might even be lucky and be able to do three.

But a green LED might have a forward voltage of 4V - so a 5V Arduino could only power one.

That's an option, but you'd also need a higher supply voltage - as noted above, it's a voltage issue rather than a current issue.

There are also dedicated LED driver chips.

Another option is called Charlieplexing - it allows you to individually control more LEDs than you have pins:

Try putting "Arduino Charlieplexing" into your favourite internet search engine...

I think this is how the LED matrix on the UNO R4 WiFi is done.

Hello

Post a schematic of your project.

You need to do something like this:
leds

2 Likes

@kitch014 - If the green LEDs are 4V, you still won't get four in series to light at 12V!

Beware that white & blue LEDs have higher forward voltages...

You're going to have to either study your LED specs or measure them to see what supply voltage you'll need given the number you want in series.

Thank you for that, is the only way to find out my LED voltage drop is to measure, or is there some clever calculation?

But very helpful link, thank you

I have created it on TinkerCad and recreated for real.

Please find a quick overview of it below, with some Mosfit. Thank you
Picture1

Is that the actual type of battery that you are using ?

Not the actual battery, just placed it to make sure the setup was working correctly, will provide accordingly when I work out how much I will need.

leds1

1 Like

No, no calculation but you can go by the values listed in the table posted by @awneil.

The forward voltage does not just depend on the LED material, though. It also depends on the current flowing in the LED. So, if you want a more accurate value of Vf, measure it at the LED current used.

I gave you two options!

Would be far easier to just look in datasheet for the specific part!

The table I linked earlier is based on the physics - they've done the calculations for you.

This is how your Fritzing layout looks on this end:
image

Please post a high resolution image.

1 Like

Indeed; eg,

In addition to the options already mentioned:

Search for Port Expanders - they connect via I2C or SPI, and give you a load of extra ports.

There are also multi-LED driver chips - again, connect via I2C or SPI, and drive a load of LEDs.

And, of course, there are the addressable LEDs - WS2812 et al - which take only 1 port pin for a huge number of LEDs

1 Like

If you want lots of LEDs that you can control individually, consider LED strips like the WS2812 strips. 1 pin to control, potentially, hundreds of LEDs, independently. Strips come in single color or RGB. A RGB LED can be one of millions of colors.

1 Like

I thought of suggesting that, but the OP mentions using 0402 LEDs so I suspect that there is a requirement for them to be small

Ah yes, that did slip my mind, thanks.

In that case, the IO expander makes sense. Like MCP23008 (8 bit, I2C), MCP23017 (16 bit I2C), MCP23S08 (8 bit, SPI), MCP23S17 (16 bit, SPI).