I search an optimised way for to handle 4 rgb leds, so 4x3(rgb) = 12 leds in "//"
With charlieplexing, I can already handle this but this work with only one led active at a time
(so only a very little time = 1/12 of the time is given for each individual r, g or b led )
What I want is to can handle 3 leds in // and chipiplexing seem the good way but I find only how to handle 6 leds with 3 pins, no 12 leds with 4 pins
=> where can I i find informations about this on the Net ?
(alls informations that I can find about this for the moment on the Net is for 3 pins for 6 leds, not 4 pins for 12 leds )
PS : I search on the other side to use multiplexing and I can already drive in // the RGB components of one RGB led, so this give already 1/4 of the time for each RGB led BUT I want to limit the number of pins and always the possiblities to drive multiples leds in the same time
No, you can - if using a sufficient driver - illuminate three LEDs simultaneously.
The "trick" is that since an Arduino is limited to 20, maybe 30 mA, this will be shared by the three LEDs unless you use four NPN buffer transistors in the matrix.
Because I find hard to find WS2812 in a standard LED package (as monochrome 2 pins or RGB common cathode 4 pins) and that I have a LOT of RGB leds and CD4052 or 74HC595 chips
Plus the fact that it is very more fun to handle what seem impossible to make than what is already existant
I think to use an external power for to aliment transistors, not the power given by the arduino
=> so, I don't think that the arduino limitation of power is really a problem since the arduino have only to aliment the base pin of the transistor, so a very limited power is used
I want to aliment 16 RGB leds, organised in 4 towers of 4 RGB leds / pins each, towers than can each individually handle 3 rgb components in the same time at about 20 mA per component per led
=> this give 4 towers x 20 mA x 3 leds(red, green and blue) = 12 x 20 mA = 240 mA for a 25% time occupation per RGB led for a multiplexing of 4 RGB leds in each tower
You might also do this with shift registers or counters.
You would need only 1 pin.
Or maybe 2 to get rid of the flickering that is visible during the load of a new pattern.
I have built this a long time ago. It worked, but was a bit slow (my counter IC included a 8 bit freq divider), so it took a visible amount of time to load a new pattern. But you might also present that as 'magic' (like the flickering and buzzing in Star Trek like devices).
Edit: you would need 2 pins at least. One for data and one for reset.
I have begin too to see about the use of 74HC595 multiplexers instead CD4052 but I have never play with 74HC595 multiplexers
(I'm too a relative beginner with CD4052 => it's why I can always dream about the use of CD4052 (analogics) AND 74HC595 (digitals) multiplexers in the same system for to greatly limit the number of used pins on the arduino/ESP32 side and with a raisonnable speed )
[2x CD4052 chips (one for the A and G components and the other for B and R components) for to handle the analogic alimentation of the actually selected RGB led(s) and/or 2x 74HC595 chips for to handle the individual selection of each RGB led / tower]
Back to the OP's post, is the question really "what is the real schematic for the 12-LED case?" Or are you no longer interested in this?
If it was me, I'd look at either 74HC595 or MCP23017 for the solution, but you may be interested in what a chipiplex 12-LED solution looks like.
C
For to begin on chippieplexing, "only" to can handle 4 RGB leds = 4x3 = 12 monochromes leds with 4 pins instead only 2x RGB leds = 2x3 = 6 monochromes leds with 3 pins ...
(I think that this need only to add one wire/transistor that is distribued like others, but I haven't the "table of true/tri-sate" for 4 pins of the chippiplexing system, I found only the "table of true/tri-state" for 3 pins = 6 leds)
Ok. You're on the right track. First, draw the schematic. Add R4 and Q4. Then, by inspection, note that each transistor emitter is connected via two LEDs, in opposition, to every other transistor emitter. So your new transistor emitter needs the same pairs, to each of the original three. There's your 12 LEDs established.
That's the first step. Now, expand the logic table to account for all of the new states, and look at the patterns needed. It's really quite simple when decomposed this way.
C
So use three pins to load a 74HC595 and use 7 of the 8 output pins to drive a 4x3 matrix. You'll need NPN transistors on the cathode drivers since the 74HC595 can only handle 70 mA total.
The problem of the 74HC595 chips is that it can only handle digitals signals (0/1 true/false 0V/3.3V) signals, not analogics signals, so only two levels = on/off per R,B and B components/leds instead an infinity between 0 and 1 with the analogic use
Note than the analogic/digital problem can to be handled via PWM, but I'm not sure that this can really work very well with the use of a "fast" multiplexing in the same time ...
(each led has to be refreshed at last at 50 Hz but 100/120 Hz seem me better => this give only somes little milliseconds between = 1000 ms / 50 Hz = 20 ms and 1000 ms / 120 Hz = 8.33 ms for each RGB led if we multiplex them ...)
And it is more practically done using NPN transistors, with their collectors going to 5 V., the emitters going only to the diode anodes and the resistors going only to the diode cathodes.
So the resistors are defining the current to the LEDs; they are not in any way a base-emitter "pull-down" to the transistors. With the NPN version, you can pull up (HIGH) one I/O while you pull down all the other I/O and light two LEDs at a time. If you extend this to four I/O pons, you can pull up one and the other three down to light three at a time. this extends to any number of I/O you choose to use.
As it depends on using I/O both going HIGH and LOW, you cannot use any voltage higher than the Arduino supply though for the NPN transistor version, you can connect any higher voltage to the collectors. The LEDs will only see the Arduino supply voltage minus the 0.7 V base-emitter drop and their current will be limited by the resistors.
The CD4052 is essentially obsolete and not useful in any way for this application. Its replacement, the 74HC4052 is not really any more useful here.
If you want to dim Charlieplexed LEDs, you write code to perform the PWM as part of the multiplexing.
The 74HC595 has an Output Enable pin that you can use to apply PWM to all eight outputs together. But it is not as suitable as an Arduino to drive LEDs.
Your description of "towers" of several RGB LEDs is confusing. You really need to plan just how many LEDs you want to control and how to matrix them, You seem to suggest multiple groups of 12 LED elements with four pins dedicated to each. That is not making appropriate use of multiplexing, so if you explain just how many RGB LEDs you actually want to use and whether they need to be controlled individually or in groups, we can perhaps sort it out.
I have make 4 towers with 4 RGB leds for each of them, where each tower use only 4 wires for to be controled
RGB 4 pins leds are only rotated by 90% at each level of the tower, so I can control the RGB led used on each tower by only set it common cathode to GND and construct the wanted color by the the 3 others R, G and B pins
=> this give me "only" 16 wires (4 for each tower x 4 towers), but I have only tested with one tower for this time, I think to test with towers in // in a very short time, but I think that to handle 4 x RGB leds = 4 x3 = 12 leds = 12 x 20 mA = 240 mA in the same time need more power than my ESP32 can handle
(and want too economise a maximum of pins on the ESP32 side if possible, since 16 OUTPUT PWM pins is the maximum that it can handle and I prefer use very less pins than this ...)
The 20 LED BADGE schema seem exactly what I want to use for each tower
But this work with 5 wires = 5 x (5-1) = 5 x 4 = 20 leds instead only with 4 wires = 4 x (4-1) = 4x3 = 12 leds that I need/search
=> this isn't a problem since I have now understand how this work exactly with yours greats advices / corrections
==> the problem is now more how to limit the total number of used pins /power on the arduino side since 4x4 = 16 OUTPUT pins (4 towers of 4 pins each) seem me too big and I prefer limit this at a maximum of about 8 or 12 pins for to have somes input/output pins that are free on the ESP32 side for to can control others things such as obtacle detection, for that the entire system can handle/animate differents figures when we turn around it for example ...
(yes, I want "the butter and the money of the butter" AND if I can have "the creamer's ass on the same time" : it's even better )
Note that an additionnal charlieplexing beween towers (instead only use the multiplexing between each RGB led on a the same tower) can certainly handle this
=> I haven't test this but this can to be a part of the solution
(but this always need 16 wires between the cube side and the arduino side when I want to limit this to only say 8 or 12 pins for to have somes free pins on the arduino side for to handle others things ...)
In french terms, we say "Avoir le beurre et l'argent du beurre" and the general response is something like "tu ne veux pas te taper la crémière en même temps tant qu'on y est ?"
"tu ne veux pas" == "you do not want"
"te taper la crémière" == "kick your ass"
"en même temps" == "at the same time"
"tant qu'on y est" == "for that matter"