Saving microcontroller pins to drive seven segment display
One strategy used to reduce pin count uses a 74HC164-type shift register that only requires two pins (data and clock) to shift out at least 8 bits. More chips can be daisy-chained for more output.
The processor would contain table lookup that could emulate a 74LS47. Or you can invent your own segment sequences. Dout1 and Dout2 are general-purpose GPIO pins, set to be "digital output" pins.
Shifting can be done quite quickly, so that the LED segments are barely lit as the bit sequence is shifted out. However, a ghost image is hard to avoid.







simulate this circuit &ndash; Schematic created using CircuitLab