EMBEDDED SYSTEMS & MICROCONTROLLERS · PAGE 32
Driving LEDs and Seven-Segment Displays
Many lights, few pins.
Each LED needs a current-limiting resistor. Compute it as supply minus LED voltage, divided by the desired current.
Multiplexing lights one digit at a time, very fast, so the eye sees all of them. A four-digit display then needs about twelve pins instead of twenty-eight.
Shift registers add outputs using only three MCU pins.