Circuit Diagram
The theory behind the multiplexing technique is simple. All the similar segments of multiple LED displays are connected together and driven through a single I/O pin. In the circuit below, the seven segments are connected to PORTB through current limiting resistors Rs. A particular segment is active when the corresponding PORTB pin is low. However, it will not glow until itβs anode is connected to Vcc. You can see the anodes of the four LED displays are not directly connected to Vcc. Instead, 4 PNP transistors are used as switches to connect or disconnect the anode terminals from Vcc.
When the base of the PNP transistor is low, the transistor conducts and corresponding digitβs common anode is connected to Vcc. Therefore, the transistor selects which displays is active. The conduction of the transistors are controlled by RA0 through RA3 pins of PORTA. Suppose, if we want to display 7 in the units digit place, then segments a, b, and c should be turned on first (which means RB0, RB1, RB2 are 0 and RB3-RB6 are 1) and then RA0 should be pulled low (while keeping RA1-RA3 high) so that only units digit display will be active. In order to display all 4 digits, each seven-segment display is activatedΒ sequentially using an appropriate refresh frequency so that it will appear that all the them are turned on at the same time.