Multiplexing vs decoder

Hello everyone! I'm new on this forum. If i have 16 leds, multiplexing them will result in 8 pins of my arduino. Using a decoder is a bad idea? It will take only 4 pins. Do they not switch so fast or why people do not use them with leds?

You will want to provide a way of turning off the decoder's outputs while you change the decoder's inputs, otherwise you end up with ghosting. That will probably take another pin.

Depends a lot on what you actually want to do.

How many LEDs need to light at once? Do they only light in groups?

If you multiplex, and any number may need to appear lit at once, then a four by four multiplex means each row (or column; same import) is lit only one quarter of the time which limits the maximum brightness (even when you are prepared to drive the LEDs for more than their continuous rating for that proportion of the time).

If you use a one of sixteen decoder, then each LED is lit only one sixteenth of the time, so you lose even more brightness. In addition, the decoder chip is limited in the amount of current it can provide anyway, generally 20 mA for a HC series IC. You could turn the LEDs on for longer periods when fewer than the full number need to be lit, but then the brightness varies according to the number illuminated. Same applies to multiplexing.

That is the reason you do not see decoders used to drive displays.

To save port pins, you use shift registers. In addition, these allow you to simply set a pattern and leave it until you need to change it. 74HC595s however, can provide 20 mA to an output, but only for about three outputs at most, so you want to look at TPIC6B595s which can sink a lot of current.

That is two chips (and three pins) to drive your 16 LEDs. If you want to do more than 24 LEDs, multiplex with a MAX7219.

Yes, MAX7219, only need 3 IO pins. Moves the multipexing to another chip.
Or daisy chain two TPIC6B595, same 3 pins.