Circuit for connecting multiple bi-color 2 pin LEDs

I need to control approx 40 pairs of bi-color LEDs. 10 to start with, adding more over time for a total of 40 pairs (80 bi-color LEDS in total). About 80% of the pairs will be ON at any given time so I think I need to power them from an external power supply.

The LEDs act as indicators and are spread out on a panel and not in any physical row/column matrix.
All LEDs are 2 pin bi-color, draw 20mA each, and need to be controlled as sets of pairs with 3 states per pair.

State 1 - both OFF
State 2 - first LED is ON, showing Red, second in pair is ON showing Green
State 3 - first LED is ON, showing Green, second in pair is ON showing Red

The LED pair's state is dependent upon multiple sensors providing input via 74HC165 shift register and also input to the nano is keyed into a connected PC.

An input is expected on average of 2 secs requiring the display to be updated 2 secs average.

I have successfully connected 1 pair via shift register as proof of concept where each LED is connected to 2 outputs from shift register(74HC595). A set of 4 register outputs work as a pair, both low, high/low or low/high to match the 3 states.

Diagram and test piece of code is attached.

Question : Not sure if this is the best way to design this circuit. If I were to supply power to the LEDs could I use a transistor between the shift register and the LED, and if so how should I put the circuit together please?

Any help would be greatly appreciated.

#define Q14_Data              4
#define Q12_Latch             5
#define Q11_Register_Clock    6

void setup()
{
  pinMode(Q14_Data, OUTPUT);
  pinMode(Q12_Latch, OUTPUT);
  pinMode(Q11_Register_Clock, OUTPUT);

  digitalWrite(Q12_Latch, LOW);
  
// set all LEDS OFF

  shiftOut(Q14_Data, Q11_Register_Clock, LSBFIRST, 0); 
  digitalWrite(Q12_Latch, HIGH);
}

void loop()
{

// Test code to validate one pair of LED's 

    digitalWrite(Q12_Latch, LOW);
    shiftOut(Q14_Data, Q11_Register_Clock, LSBFIRST, 0b10010000);
    digitalWrite(Q12_Latch, HIGH);
    delay(1000);

    digitalWrite(Q12_Latch, LOW);
    shiftOut(Q14_Data, Q11_Register_Clock, LSBFIRST, 0b01100000);
    digitalWrite(Q12_Latch, HIGH);
    delay(5000);   
}

Bi-Color LED Power and Control.png

Bi-Color LED Power and Control.png

Question : Not sure if this is the best way to design this circuit.

Nothing else springs to mind, sounds as good as it gets.

Why would you want to add a transistor? What you would need is four transistors in a H-bridge arrangement if you are running into current limiting problems. Note you don’t have to run LEDs at the maximum current, often 5 to 10mA is sufficient when looking directly at them. You don’t want to make them too bright especially as there are so many of them.

if my final target were 40 individual LEDs, I wouldn't use shift registers nor LED driver IC's, I would go for addressable LEDs aka "neopixel" or WS2811. These LEDs are also available as APA106 in a common 5mm LED form also. OK, they are RGB, but very easy to control and very easy to wire.

Bi-Color LED Power and Control.png

OK, well for this application, 74HC595s sound just fine as they are cheap, will drive four of these LEDs each and can be chained so that 20 registers to control 80 bi-colour LEDs will still require only three control lines.

"Port expanders" such as the PCF8575 are not appropriate for this purpose.

noiasca suggests "NeoPixels" but I suspect you may be wishing to use 3mm LEDs and the NeoPixels are not available in that size.

As Mike points out, you do not want to operate them at 20 mA - this is a bit much for the 74HC595s, 10 mA will be sufficient and not a great deal less bright.

It might get a bit more tricky if you wanted to show yellow by alternating a LED between red and green.

Please read the forum instructions regarding how to post your code in a useful manner.

Thanks for the replies. Apologies for not posting the code in the correct manner.

I would like to stick to the 3mm LEDs if at all possible.

I was asking about transistors because even at 10mA, 80% of the max 80 LEDs lit at any one time implies 640mA draw - even at 5mA it is 320mA.

I will research the H-bridge arrangement suggestion.

You would only need transistors if the current required from each chip pin exceeds its maximum, or you are exceeding the overall maximum of the chip. For 74hc595, the pin maximum is 35mA, but the more serious problem is often the 70mA overall maximum.

"Port expanders" such as the PCF8575 are not appropriate for this purpose.

But what about mcp23017? It's outputs can source and sink and "tri-state". Maybe 5x mcp23017 and 10x 74hc04 could drive all 80 LEDs?

dpaul21:
Thanks for the replies. Apologies for not posting the code in the correct manner.

Easily fixed, jut modify your first post to include the code. Option under "More" to the bottom right of your post.

dpaul21:
I would like to stick to the 3mm LEDs if at all possible.

Thought as much!

dpaul21:
I was asking about transistors because even at 10mA, 80% of the max 80 LEDs lit at any one time implies 640mA draw - even at 5mA it is 320mA.

No need for transistors. At 10 mA per LED, each 74HC595 will be drawing only 40 mA, well within its ratings.

PaulRB:
For 74hc595, the pin maximum is 35mA, but the more serious problem is often the 70mA overall maximum.

So driving four LEDs at 10 mA each is 40 mA.

Vastly cheaper than a MCP23017! :astonished:

Paul__B:
So driving four LEDs at 10 mA each is 40 mA.

Hmm.. that raises a question in my mind. Data sheet says

Continuous current through VCC or GND ±70 mA

With 4 LEDs, it could be sourcing 40mA and sinking 40mA. So that's 80mA in total passing through the chip. The same 40mA of current, twice, but the chip doesn't know that. That's definitely within spec?

Paul__B:
Vastly cheaper than a MCP23017! :astonished:

True enough! I was trying to simplify rather than save money. But didn't really achieve that either. I said 10x 74hc04 but actually it would be 14x, so 19 chips in total.

2-pin, bicolor, so they are devices like these, wired up like this?
I would think that would be fine current-wise as long as you select Rs to limit output current to 70mA/4 max.

Lot of shift registers tho. A string of WS2812B as suggested would be much less to wire up, with Neopixel library or FastLed.h library to control them.

PaulRB:
With 4 LEDs, it could be sourcing 40mA and sinking 40mA. So that's 80mA in total passing through the chip. The same 40mA of current, twice, but the chip doesn't know that. That's definitely within spec?

Read what you quoted again!

Continuous current through VCC or GND ±70 mA

There is not 80 mA in total passing through the chip. Only 40 mA.

I think the datasheet says that is 70mA for each pin. So 40mA in and 40mA out is fine.

So if I use a 470 Ohm resistor I would draw a max of 6.4mA per LED. 8 LEDs per chip would draw 52 mA per chip, no transistors required.

Can you please help me understand if there would still be issues with the nano itself supplying the power - 64 LEDs (80% of 80) on at a time drawing a total of about 410 mA.

Thank you

A Nano does not supply power at all - it is not a power supply so this question makes no sense. :roll_eyes: You need a regulated 5 V power supply, and you feed it into the "5V" pin on the Nano. A very practical power source is a USB "phone charger" rated at 1 Amp or 2.1 Amp as these are ratings that match the iPhone and iPad.

While you can simply plug these into the USB connector and your application as so far described is not voltage critical, you lose a fraction of a Volt in the diode between USB connector and "5V" pin (which is itself only rated for something between ½ and 1 Amp), so connecting your 5 V directly to the "5V" pin (as well as all other 5 V devices) is far better. :grinning:

Thanks everyone for all your help.

Paul__B:
Read what you quoted again!There is not 80 mA in total passing through the chip. Only 40 mA.

Ok, get it.

So...

When the data sheet says

Continuous current through VCC or GND ±70 mA

we can interpret this as

Continuous current through VCC +70 mA
Continuous current through GND -70 mA

?

Does this mean that if I wanted to use the chip to drive 8 leds at 17.5mA each, using correctly calculated series resistors, I could connect 4 LEDs between Vcc and Q0 to Q3 and the remaining 4 LEDs between GND and Q4 to Q7, and not be violating the maximum ratings?

PaulRB:
Does this mean that if I wanted to use the chip to drive 8 leds at 17.5mA each, using correctly calculated series resistors, I could connect 4 LEDs between Vcc and Q0 to Q3 and the remaining 4 LEDs between GND and Q4 to Q7, and not be violating the maximum ratings?

I cannot see why not.

Each of the output lines is only carrying your 17.5 mA in one direction or another, and the Vcc and Ground pins are each carrying 70 mA. The restrictions would relate to the current density in the region of the bonding pads on the chip and in this case, the current is evenly distributed over different regions, different interconnects and different output FETs.

Of course I would not cut it that fine. :grinning:

Thanks! I'll file that idea away for a future opportunity.

See what Mike has to say. :grinning: