Multiplexing RGB LEDs

Method to Multiplex 10 RGB LEDs with 5 PNP transistors and a 74HC595.
Limit current into 74HC595 to 70mA MAX.

Thanks,
do you have some code too?
does this work with PWM too?

(yes I know one mad men can ask more than 10 wise can answer;)

Sure, put PWM on the OE pin instead of grounding it.

#include <SPI.h>
byte pinArray[] = {2,3,4,5,6,}; // Arduino pins
byte dataArray[5]; // data to turn RGBs on/off, 1 byte per row, bit 6-7 not used in this example
byte rowEnable;
byte ssPin = 10;
byte x;

unsigned long currentmillis;
unsigned long priormillis;
unsigned long duration = 5; // 5 mS udpates, 25mS total refresh time (40 Hz)

void setup(){
// setup output pins, HIGH to turn off PNPs
for (x=0; x<5; x=x+1){
pinMode (pinArray[x], OUTPUT);
digitalWrite (pinArray[x], HIGH);
}
pinMode (ssPin, OUTPUT);
digitalWrite (ssPin,  HIGH);
SPI.begin();
}
void loop(){
// My method to multiplex a display
// Loop thru the row, but update when a time has elapsed
// Is a for-next loop, but with time check mixed in, so traditional for-next format is broken up
// see if time to change the display
currentmillis = millis();
if ( (currentmillis - priormillis)>=duration){
// set up for next time check
priormillis = priormillis + duration;
// turn off prior row
digitalWrite(pinArray[rowEnable], HIGH);
// set up for the next row - this is where the for-next is broken up
rowEnable = rowEnable +1;
// reset when reach the end
if (rowEnable ==5){
rowEnable = 0;}
// write cathode data
digitalWrite(ssPin, LOW);
SPI.transfer(dataArray[rowEnable]);
digitalWrite(ssPin, HIGH);
// Enable Anode
digitalWrite(pinArray[rowEnable], LOW);
} // end dataArray writing

// code to perform dataArray goes here

} // end void loop

Compiled & passes. Up to user to develop code towards the end to define what is displayed.

It looks nice, but the specific parts (like a bill of materials) would make it easier. It looks like things are limited to 60mA, would about any npn transitor would work?

LED specifications will vary, so its hard to build the BOM when you dont know the LEDs forward voltage or current specifications.

It looks to me that you are planning on running the LEDs at about 10ma, to keep the shift register down to 60mA. That does require that only one transistor is turned on, and should something cause more than one transistor being on(program crash,...), could cause a situation where more than 70mA could happen.

This would also be a handy circuit for controlling 30 LEDs.

P.S. Im still working on a 64 RGB LED cube with 20 NPN transistors Im using tiny 2n2222s to sink upto 240mA.

This might be a curious way to make a 10x10x10 RGB LED cube or 10x10 matrix.

LED size - 3mm, 5mm, 10mm, SMD, thruhole, infinite choices of brightness. Same for Vf.
Transistor must be PNP, not NPN.
Shift register can be 74HC595, or TPIC6B595 for more current sinking capacity.
Resistors sized to suit the other components.

That's why no BOM is provided.
Expand it higher or wider as needed.

More LEDs connected

It looks like you have 100 RGB LEDs going on there, and a short BOM to boot. Nice work.

If im not mistaken, that looks like:
100 RGB LEDs
310 resitors
10 PNPs
4 shift registers.

424 parts. Thats pretty good when you consider that you are lighting up 300 LEDs.

Im not sure, but it looks like making a 10x10x10 cube is just another 10 more transistors.

No, only 40 resistors - 10 on PNP bases, and 30 on the shift register outputs (which I didn't show - will have to fix that - this was modified from a WS2803 example which didn't need individual resistors)

10x10x10 cube - yes, 1 more transistor to enable each row,
and of course something to drive them all.
This card has 96 open-drain outputs. I'm thinking 81 cathode sinks, and 9 pnp gate sinks for a 9x9x9 cube.

I used 2 cards, with 2nd card having only shift registers daisy chained off the first, to drive a non-multiplexed 20 column display

That card looks pretty nice, one day I should try doing things the easy way.

So... lets see if I can get the BOM approximation:

10x10 RGB Matrix:

100 RGB LEDs (too many options to list, but may effect other parts values)
40 resitors (10 x ??? for transistors, 30 for cathodes (values vary depending on many factors))
10 PNPs transistors (Part suggestion? 3906 is too small?)
4 Shift registers (could be 74hc595, TPIC6B595, ...)
4 decoupling caps (Probably .1uf ceramic cap)

158 parts to control 100 RGB LEDs.

10x10x10
1,000 RGB LEDs
50 resistors (20x ??? for transistors, 30 for cathodes)
20 PNPs (unsure, two sets of 10 or maybe one set of 20, depending on other factors)
4 shift registers
4 decoupling caps

178 parts to control 1,000 RGB LEDs.

Can that be right?

Lets say we wanted to go crazy, and use mosfets instead of BPJs Would that make any significant differences in design? energy consumption?
If my 4x4x4 transistor cube works out well, I was thinking of doing the same thing with some tiny mosfets.

I think you have the BOM correct.
I personally would use TPIC6B595 (as shown on my card) so that the design is not limited by the 74HC595's 70mA total current sink capability,
and some kind of P-channel logic level MOSFET with low Rds, then additional TPIC6B595 could be used to pull the gates low to turn them on, and simple resistors to pull the gates high to turn them off. My board populated with 7 TPIC6B595 would be sufficient to drive the 30 cathodes in the rows, the 10 row enable transistors, and the 10 layer enable transistors.

Updated to show missing current limit Rs and expansion with Layer transistor to support multipexing of a 10x10x10 RGB cube.