LED GURUcosycom.com
PAGE 114 OF 150 · MICROCONTROLLERS & LEDS

Driving a Seven-Segment with a Microcontroller

Lookup tables map digits to segments.

LED SYMBOLTriangle points from anode to cathode; the arrows show light leaving the part.

Direct drive

A single digit needs seven segment pins plus one for the decimal point, each with a 220 to 330 ohm resistor. Keep the segment patterns in an array, one number per digit.

More digits

  • Multiplex the digits by switching each common pin with a transistor.
  • Refresh the full display at 100 Hz or more.
  • Use a shift register or MAX7219 to save pins.

Add up the current: eight segments at 10 mA is 80 mA, which can exceed a chip's total limit. A driver chip keeps the load off the microcontroller.

REMEMBER
Store digit patterns in a table and look them up.

Try it yourself

Sketch the circuit on paper first, calculate the values, then build it on a solderless breadboard using a low-voltage supply. Measure with a multimeter before you make anything permanent.

Explore LED clocks, stopwatches and electronics at cosycom.com.

Watch: COSYCOM channel videos

www.youtube.com/@cosycom