7-Segment Display Decoder
Pick 0–F to see which segments light, the BCD input, and the hex byte to send from a microcontroller.
Segment names and cautions
Going clockwise from the top the segments are a, b, c, d, e, f, with g in the middle. A common-cathode display lights on High, a common-anode one on Low. BCD decoder ICs such as the 74LS47 only show 0–9 as digits, draw 6 and 9 without tails (no a or d), and show odd symbols for 10–15. Each segment needs its own current-limiting resistor.
Worked example: the segment code for 2
- The digit 2 lights the top (a), upper right (b), middle (g), lower left (e) and bottom (d) → a b d e g
- In the order g f e d c b a with lit = 1: 1 0 1 1 0 1 1 → common-cathode code 0x5B
- A common-anode display lights on Low, so invert every bit → 0xA4
7-segment code table for 0–F
| Digit | Lit segments | DCBA | g f e d c b a | Common cathode | Common anode |
|---|---|---|---|---|---|
| Digit0 | Lit segmentsa b c d e f | DCBA0000 | g f e d c b a0 1 1 1 1 1 1 | Common cathode0x3F | Common anode0xC0 |
| Digit1 | Lit segmentsb c | DCBA0001 | g f e d c b a0 0 0 0 1 1 0 | Common cathode0x06 | Common anode0xF9 |
| Digit2 | Lit segmentsa b d e g | DCBA0010 | g f e d c b a1 0 1 1 0 1 1 | Common cathode0x5B | Common anode0xA4 |
| Digit3 | Lit segmentsa b c d g | DCBA0011 | g f e d c b a1 0 0 1 1 1 1 | Common cathode0x4F | Common anode0xB0 |
| Digit4 | Lit segmentsb c f g | DCBA0100 | g f e d c b a1 1 0 0 1 1 0 | Common cathode0x66 | Common anode0x99 |
| Digit5 | Lit segmentsa c d f g | DCBA0101 | g f e d c b a1 1 0 1 1 0 1 | Common cathode0x6D | Common anode0x92 |
| Digit6 | Lit segmentsa c d e f g | DCBA0110 | g f e d c b a1 1 1 1 1 0 1 | Common cathode0x7D | Common anode0x82 |
| Digit7 | Lit segmentsa b c | DCBA0111 | g f e d c b a0 0 0 0 1 1 1 | Common cathode0x07 | Common anode0xF8 |
| Digit8 | Lit segmentsa b c d e f g | DCBA1000 | g f e d c b a1 1 1 1 1 1 1 | Common cathode0x7F | Common anode0x80 |
| Digit9 | Lit segmentsa b c d f g | DCBA1001 | g f e d c b a1 1 0 1 1 1 1 | Common cathode0x6F | Common anode0x90 |
| DigitA | Lit segmentsa b c e f g | DCBA1010 | g f e d c b a1 1 1 0 1 1 1 | Common cathode0x77 | Common anode0x88 |
| DigitB | Lit segmentsc d e f g | DCBA1011 | g f e d c b a1 1 1 1 1 0 0 | Common cathode0x7C | Common anode0x83 |
| DigitC | Lit segmentsa d e f | DCBA1100 | g f e d c b a0 1 1 1 0 0 1 | Common cathode0x39 | Common anode0xC6 |
| DigitD | Lit segmentsb c d e g | DCBA1101 | g f e d c b a1 0 1 1 1 1 0 | Common cathode0x5E | Common anode0xA1 |
| DigitE | Lit segmentsa d e f g | DCBA1110 | g f e d c b a1 1 1 1 0 0 1 | Common cathode0x79 | Common anode0x86 |
| DigitF | Lit segmentsa e f g | DCBA1111 | g f e d c b a1 1 1 0 0 0 1 | Common cathode0x71 | Common anode0x8E |
Codes use the bit order dp g f e d c b a (a is the least significant bit) with the decimal point off. BCD decoders such as the 7447 show different shapes for 10–15.
Using it in practice
Step by step
- Choose common cathode or common anode to match your display.
- Pick a digit from 0 to F and see which segments light, the BCD input and the byte to send.
- Check the bit order the tool uses against how you wired segments a to g to your port.
Common mistakes
- Wrong display type. A common-anode display lights a segment when its pin is pulled low, so every bit is inverted compared with common cathode. If your digits look like negatives, this is why.
- One resistor in the common lead. With a single shared resistor, the brightness changes with the number of lit segments (an 8 is dimmer than a 1). Use one resistor per segment.
- Pairing the wrong decoder. The 7447 has active-low outputs for common-anode displays; the 7448 and CD4511 drive common-cathode displays.
Practical tips
Segments are labelled a to g clockwise from the top, with g in the middle and dp for the decimal point. Pinouts vary between display models, so find the common pins with a meter on diode test before wiring. To drive several digits, multiplex: light one digit at a time fast enough (above roughly 100 Hz per digit) that the eye sees them all, and raise the segment current to make up for the shorter on-time.
Frequently asked questions
What hex codes show 0–9 on a common-cathode display?
With bit 0 = a through bit 6 = g: 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F. For a common-anode display invert the bits (0xC0 for 0).
Why does my 74LS47 show strange symbols for 10–15?
The 74LS47 is a BCD decoder: it is designed for 0–9 only, and inputs 10–15 produce fixed special patterns rather than A–F. Use a microcontroller or a hex decoder to show A–F.