user609: We need to control many leds, about 40 with arduino (UNO) and we need some remain turned on and other off at the same time. Muted or pinned vary constantly. 
What should I use to do this, I have several Multiplexers CD4051 but with these I can just light a LED at a time.
I do some calculation and then need to turn LEDs 1,2,5,7 and need to be pinned to the following calculation. In the following calculation I need to turn leds 4, 5, 10, 12 pinned and need to follow. What I need is something like that
With the multiplexer I can turn the LEDs I need and with minimal delay and it seems they are apprehended while, but I want to know if there is another alternative to do so

user368: The most common technique for doing this is called "multiplexing". You arrange the 40 LEDs into 8 "columns" and 5 "rows" with common anodes and cathodes, and then you switch the columns or rows on or off individually, activating only the LEDs you want lit for that column or row. If done quickly enough it appears to the human eye that the LEDs are always lit due to persistence of vision. Note that the physical display does not need to be a rectangle; this is simply the logical arrangement used in order to simplify the circuit.

(note that the cathode side of the above image is wrong; the cathode needs to be low when you want the LED to light)
(source)
A naive implementation with 8 columns and 5 rows would use 13 pins to connect them all. However, since you don't need more than one column at a time what you can do is use a 74HC138/238 to use 3 inputs to control which of the 8 columns you want to activate. This drops the number of required pins to 8, which is low enough for anything larger than a ATtinyX5. Use of a 74HC595 for the 8 pins further drops the required MCU pins to 3, which is low enough for even a ATtiny4/5/9/10, but the timing is harder to get right due to the shift register.

609: <p>We need to control many leds, about 40 with arduino (UNO) and we need some remain turned on and other off at the same time. Muted or pinned vary constantly. 
What should I use to do this, I have several Multiplexers CD4051 but with these I can just light a LED at a time.</p>

<p>I do some calculation and then need to turn LEDs 1,2,5,7 and need to be pinned to the following calculation. In the following calculation I need to turn leds 4, 5, 10, 12 pinned and need to follow. What I need is something like that</p>

<p>With the multiplexer I can turn the LEDs I need and with minimal delay and it seems they are apprehended while, but I want to know if there is another alternative to do so</p>
 368: <p>The most common technique for doing this is called <a href="http://en.wikipedia.org/wiki/Multiplexed_display" rel="nofollow noreferrer">"multiplexing"</a>. You arrange the 40 LEDs into 8 "columns" and 5 "rows" with common anodes and cathodes, and then you switch the columns or rows on or off individually, activating only the LEDs you want lit for that column or row. If done quickly enough it appears to the human eye that the LEDs are always lit due to <a href="http://en.wikipedia.org/wiki/Persistence_of_vision" rel="nofollow noreferrer">persistence of vision</a>. Note that the <em>physical</em> display does not need to be a rectangle; this is simply the <em>logical</em> arrangement used in order to simplify the circuit.</p>

<p><img src="https://i.stack.imgur.com/UCqdw.gif" alt="LED multiplexing demonstration"></p>

<p><em>(note that the cathode side of the above image is wrong; the cathode needs to be <strong>low</strong> when you want the LED to light)</em></p>

<p><a href="http://www.franksworkshop.com.au/Electronics/RGB/RGB.htm" rel="nofollow noreferrer">(source)</a></p>

<p>A naive implementation with 8 columns and 5 rows would use 13 pins to connect them all. However, since you don't need more than one column at a time what you can do is use a <a href="http://www.ti.com/product/cd74hct138" rel="nofollow noreferrer">74HC138/238</a> to use 3 inputs to control which of the 8 columns you want to activate. This drops the number of required pins to 8, which is low enough for anything larger than a ATtinyX5. Use of a 74HC595 for the 8 pins further drops the required MCU pins to 3, which is low enough for even a ATtiny4/5/9/10, but the timing is harder to get right due to the shift register.</p>
