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 | DCBA | Lit segments | g f e d c b a | Common cathode | Common anode |
|---|---|---|---|---|---|
| 0 | 0000 | a b c d e f | 0 1 1 1 1 1 1 | 0x3F | 0xC0 |
| 1 | 0001 | b c | 0 0 0 0 1 1 0 | 0x06 | 0xF9 |
| 2 | 0010 | a b d e g | 1 0 1 1 0 1 1 | 0x5B | 0xA4 |
| 3 | 0011 | a b c d g | 1 0 0 1 1 1 1 | 0x4F | 0xB0 |
| 4 | 0100 | b c f g | 1 1 0 0 1 1 0 | 0x66 | 0x99 |
| 5 | 0101 | a c d f g | 1 1 0 1 1 0 1 | 0x6D | 0x92 |
| 6 | 0110 | a c d e f g | 1 1 1 1 1 0 1 | 0x7D | 0x82 |
| 7 | 0111 | a b c | 0 0 0 0 1 1 1 | 0x07 | 0xF8 |
| 8 | 1000 | a b c d e f g | 1 1 1 1 1 1 1 | 0x7F | 0x80 |
| 9 | 1001 | a b c d f g | 1 1 0 1 1 1 1 | 0x6F | 0x90 |
| A | 1010 | a b c e f g | 1 1 1 0 1 1 1 | 0x77 | 0x88 |
| B | 1011 | c d e f g | 1 1 1 1 1 0 0 | 0x7C | 0x83 |
| C | 1100 | a d e f | 0 1 1 1 0 0 1 | 0x39 | 0xC6 |
| D | 1101 | b c d e g | 1 0 1 1 1 1 0 | 0x5E | 0xA1 |
| E | 1110 | a d e f g | 1 1 1 1 0 0 1 | 0x79 | 0x86 |
| F | 1111 | a e f g | 1 1 1 0 0 0 1 | 0x71 | 0x8E |
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.
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.