Using the converter
Type digits or a short word. You get one byte per digit, ready to paste into a lookup table, and a drawing of how the display will look. A full stop after a digit lights its decimal point, so 12.34 still takes four digits.
Pick the bit order your wiring uses and whether the display is common cathode or common anode. Swap the boxes to go the other way: paste codes such as 0x3F 0x06 and read the digits they draw.
How the segments are named
The seven bars are labelled a to g. Start at the top bar, a, and go clockwise round the outside, ending with f on the upper left. The middle bar is g. The decimal point, DP, is sometimes called the eighth segment.
One byte holds the whole state of a digit. The two common bit layouts are gfedcba and abcdefg. In gfedcba, a is the lowest bit, so 0x06 lights b and c and shows a 1. This tool puts DP in the top bit, 0x80, in both layouts.
7-segment hex code chart
| Shows | Segments | gfedcba | abcdefg | Common anode |
|---|---|---|---|---|
| 0 | abcdef | 0x3F | 0x7E | 0xC0 |
| 1 | bc | 0x06 | 0x30 | 0xF9 |
| 2 | abdeg | 0x5B | 0x6D | 0xA4 |
| 3 | abcdg | 0x4F | 0x79 | 0xB0 |
| 4 | bcfg | 0x66 | 0x33 | 0x99 |
| 5 | acdfg | 0x6D | 0x5B | 0x92 |
| 6 | acdefg | 0x7D | 0x5F | 0x82 |
| 7 | abc | 0x07 | 0x70 | 0xF8 |
| 8 | abcdefg | 0x7F | 0x7F | 0x80 |
| 9 | abcdfg | 0x6F | 0x7B | 0x90 |
| A | abcefg | 0x77 | 0x77 | 0x88 |
| b | cdefg | 0x7C | 0x1F | 0x83 |
| C | adef | 0x39 | 0x4E | 0xC6 |
| d | bcdeg | 0x5E | 0x3D | 0xA1 |
| E | adefg | 0x79 | 0x4F | 0x86 |
| F | aefg | 0x71 | 0x47 | 0x8E |
Common cathode or common anode?
In a simple LED package all the cathodes, or all the anodes, are joined to one common pin. On a common-cathode display you drive a segment pin high to light it. On a common-anode display you pull it low, so every bit in the code is flipped.
Not sure? Check the datasheet. Wrong wiring is easy to spot, because the display lights the gaps around the digit and leaves the digit itself dark.
Letters on seven segments
Hex digits B and D are shown in lowercase, as b and d, so they are not confused with 8 and 0. The 6 keeps its top bar for the same reason, or it would look like a b.
Many other letters fit, though some only in lowercase (n is one). A few clash with digits: I looks like 1, S like 5 and Z like 2. Some letters have no usable shape at all. K is the classic example. The converter leaves those out and tells you.
Questions
What is the 7-segment code for 0?
0x3F in gfedcba order on a common-cathode display. That lights every segment except g, the middle bar.
Why does my display show the wrong segments?
Usually the bit order is the other way round from your code, or the display is common anode and needs inverted codes. Try the other settings and compare.
Can it show a colon for a clock?
Clock colons are separate LEDs on most modules, not part of a digit, so the converter skips colons. 12:45 comes out as four digits.
Sources
- Wikipedia: Segment display, seven-segment display
- Wikipedia: Template:7seg (segment patterns for letters)
Added and reviewed . What's new


