Hex to 7-Segment Display Converter
Hex to 7-Segment Display Converter. Enter a Hex Digit (0-F) and the Hex to 7-Segment Display Converter instantly shows you the Lit Segments. The fastest way to decode a two's complement hex value into a signed decimal number is the hex to signed integer converter.
Type a hexadecimal digit and the Hex to 7-Segment Display Converter hands back the abcdefg segment pattern that makes the character glow on a seven segment display, along with the binary string and the byte you load into a port. You get the answer for both display polarities, so you can wire a clock, a counter or a diagnostic readout without sketching a truth table by hand.
How the Hex to 7-Segment Display Converter Works
A 7-segment display is a single numeral built from seven segments named a through g, arranged in a figure-eight with an optional decimal point. Each segment is one LED or one LCD bar, and it is either active (logic 1) or inactive (logic 0). Because seven segments give 128 possible combinations, the converter only needs to know which of the sixteen hex digits you want and which polarity your hardware uses.
The conversion itself is a lookup. The converter takes a hexadecimal input, splits it into 4-bit nibbles, and maps every nibble to a 7-bit code. That code is returned as a list of lit letters, as a binary string and as a hex byte, so you can paste whichever format your project expects.
Think of the tool as a simulator and a generator in one. As a simulator it shows which segment combinations light up on a drawn display, and as a generator it produces the binary code you paste into firmware. It is also an educational aid: you can decode any byte back to its character, and the pattern table works as a tiny character encoding for symbols and numbers on any LED display.
From hex digit to abcdefg segments
Each digit from 0 to 9 and each letter from A to F has one fixed set of lit segments. The digit 7, for instance, lights only a, b and c. The converter writes the pattern as gfedcba, so segment a sits in the lowest bit and segment g in the highest, which matches the way a port register is normally wired. A segment that should illuminate is written as 1, and a segment that stays dark is written as 0. Every part’s datasheet lists the same display format, so you can cross-check the converter against the manufacturer’s own table.
Common cathode and common anode polarity
- Common cathode: every LED cathode is tied to ground, so a segment turns on when its input is driven high (logic 1).
- Common anode: every LED anode is tied to the supply, so a segment turns on when its input is pulled low (logic 0).
A common cathode display and a common anode display use the same segment letters, only with every bit inverted. The converter flips the pattern for you, which removes the most frequent wiring mistake with these parts.
7-Segment Display Decoder Truth Table for Hex Digits 0 to F
The table below is the complete truth table for a common cathode display, with segment a in the lowest bit. Use it to check any result the converter returns, or to design your own decoder logic. The fastest way to get a rough Benjamin Moore paint name for a hex value is the hex to benjamin moore converter.
| Hex digit | Binary (8421) | Segments lit | Pattern gfedcba | Byte |
|---|---|---|---|---|
| 0 | 0000 | abcdef | 0111111 | 3F |
| 1 | 0001 | bc | 0000110 | 06 |
| 2 | 0010 | abdeg | 1011011 | 5B |
| 3 | 0011 | abcdg | 1001111 | 4F |
| 4 | 0100 | bcfg | 1100110 | 66 |
| 5 | 0101 | acdfg | 1101101 | 6D |
| 6 | 0110 | acdefg | 1111101 | 7D |
| 7 | 0111 | abc | 0000111 | 07 |
| 8 | 1000 | abcdefg | 1111111 | 7F |
| 9 | 1001 | abcdfg | 1101111 | 6F |
| A | 1010 | abcefg | 1110111 | 77 |
| b | 1011 | cdefg | 1111100 | 7C |
| C | 1100 | adef | 0111001 | 39 |
| d | 1101 | bcdeg | 1011110 | 5E |
| E | 1110 | adefg | 1111001 | 79 |
| F | 1111 | aefg | 1110001 | 71 |
Why b and d are lowercase
An uppercase B would light the same segments as the digit 8, and an uppercase D would look like a 0. Displays therefore show a lowercase b and d, while A, C, E and F stay uppercase. That is the convention behind every hexadecimal character set on these parts.
Worked Example: Decoding 0x9C on a Seven Segment Display
Suppose you want a two-digit readout to show the hexadecimal byte 0x9C. The upper nibble is 9 and the lower nibble is C, so you need one pattern for each of the two digits. The decimal value of the whole byte is 9 × 16 + 12 = 156.
The segment code for a digit is a weighted sum of its bits, where each lit segment contributes a power of two:
$$\text{byte} = \sum_{s=a}^{g} b_s \times 2^{i_s}$$
Digit 9 on a common cathode display
The binary input is 1001. Segments a, b, c, d, f and g light up, giving the pattern 1101111, which is hex byte 6F (decimal 111). Six segments are active, and segment e stays dark.
Digit C on a common cathode display
The binary input is 1100. Only segments a, d, e and f light up, giving 0111001, hex byte 39 (decimal 57). Four segments are active.
The same digits on a common anode display
A common anode part needs the inverse of every bit, which is the same as subtracting from 127:
$$\text{anode byte} = 127 - \text{cathode byte}$$
Digit 9 becomes 127 − 111 = 16, which is pattern 0010000 or byte 10 in hex. Digit C becomes 127 − 57 = 70, which is pattern 1000110 or byte 46 in hex.
The current draw follows from the number of lit segments. With about 20 mA per LED, the total is:
$$I = n \times 20\ \text{mA}$$
Digit 9 draws 6 × 20 = 120 mA and digit C draws 4 × 20 = 80 mA, so the pair pulls 200 mA while 0x9C is on screen.
That result is worth checking before you build anything. A 200 mA peak is too much for a single microcontroller port, so the readout needs a transistor array or a driver chip between the pins and the segments. It also means the digit 8 is the worst case for power, because it lights all seven segments, while the digit 1 is the cheapest at only two. If the display must run from a battery, multiplexing the two digits halves the average current and keeps the readout bright enough to read.
BCD to 7 Segment Decoder vs Hex Decoder
A BCD to 7 segment decoder accepts the four binary coded decimal lines A, B, C and D and drives the seven outputs a through g. In BCD only 0000 to 1001 are valid, so values 1010 through 1111, the letters A to F, count as invalid inputs.
What the 74LS47 does with A to F
The classic 74LS47 is the workhorse decoder IC for common anode parts, and it is happy as long as the input stays between 0 and 9. Feed it a value above nine and the display turns into a garbled shape instead of a letter. A close relative, the 74LS48, behaves the same way for common cathode parts. That limit is why a plain BCD to 7-segment display decoder cannot serve as a hex readout.
Chips that support hexadecimal output
A few legacy chips, such as the MC14495, were built to produce a hexadecimal output on a seven segment display, but they are hard to buy new. Designers who still need hex output therefore turn to a programmable logic device, a lookup table in firmware, or a converter like this one to precompute the patterns. Firmware libraries often shorten the whole idea to 7seg, and a digital display decoder of any brand is simply the hardware version of the same lookup.
Hex vs BCD Input for a 7-Segment Decoder
Which patterns a decoder ever has to produce depends on what you feed it. Hexadecimal and BCD share the same 4-bit binary width but not the same meaning. In hexadecimal each nibble, which is half a byte, can hold any of sixteen values, while a BCD digit stops at nine. That difference matters in digital electronics, where several number systems meet inside one design: binary inside the processor, decimal on the face of a meter, and hex on the debug port.
Two storage layouts exist for BCD. In unpacked BCD, one decimal digit occupies a whole byte and the upper nibble stays at zero. In packed BCD, two digits share one byte, so the decimal number 47 is stored as 0100 0111. Hexadecimal numbers pack the same way, which is why a single packed byte can feed two display digits directly, one nibble to each decoder.
In digital logic design, a BCD readout needs a little more code than a hex readout. A two-digit counter that rolls over at 99 keeps its tens and units in separate nibbles, and the 74LS47 on each digit shows that nibble as one of the decimal numbers. If a plain binary code feeds the 74LS47 instead, the design must convert it to BCD first, otherwise any value past nine lights the wrong segments. That overrun is the usual cause of a garbled digit, and the 74LS47 datasheet says as much in its function table.
Driving a 7-Segment Display with a Decoder Driver
A bare 7-segment display has eight pins in the typical package: one for each segment and one common terminal. Driving it directly from a microcontroller costs seven output pins for a single digit. A 7-segment display decoder reduces that to four input lines, which is the whole reason these chips exist. The decoder reads one signal per input and drives seven output lines, one for each segment, while the display device itself only needs a supply voltage and a common return path.
Current, ground and the common pin
Every segment is a standard LED, so each one wants roughly 20 mA of forward current. Lighting all seven segments of the digit 8 therefore needs about 140 mA, which is more than most logic pins can supply. A decoder driver sinks or sources that current instead, and a series resistor on each segment keeps the LED safe. Common anode parts are popular because TTL and CMOS outputs can sink more current than they can source, so the segments are pulled to ground to light them.
Replacing a decoder with a PLD
If no off-the-shelf chip fits, a small PLD can mimic the 74LS47 pin for pin and add the missing letters. Builders of ISA POST cards used this trick so that diagnostic codes such as 3B appear as real hexadecimal characters instead of random shapes. Whether you use a PLD, an FPGA or a microprocessor lookup table, the logic you program is the same truth table shown above.
Checking a Bench Supply Error Readout with the 7 Segment Display Decoder
Marta is adding a two-digit fault readout to a bench power supply, and the firmware reports faults as one hex byte. Fault 0xE5 must show as E on the left and 5 on the right. The display is a common anode part, run from 5 V, with a 330 Ω resistor in series with each segment, and a microcontroller drives the pins directly.
She enters E5, selects common anode and clicks the Convert button. The converter returns the decimal value 229 and two bytes. Digit E comes back as 06, pattern 0000110, with segments a, d, e, f and g lit. Digit 5 comes back as 12, pattern 0010010, with a, c, d, f and g lit. Because the part is common anode, the lit segments are the zeros, so she writes 06 and 12 straight into her lookup table instead of inverting the cathode values herself.
Before wiring, she checks the load. With roughly 2.0 V across a red LED, each segment sees (5.0 − 2.0) ÷ 330 = 9.1 mA. Both digits light five segments, so ten segments draw about 91 mA. The ATmega328P datasheet allows 40 mA absolute maximum per pin and 200 mA total through the supply pins, so 9.1 mA per pin and 91 mA overall sit well inside both limits.
That number settles the design question. A decoder driver chip is not needed for this readout, so she wires the segment pins directly and keeps the 330 Ω resistors. If she later wants fault 0x88, which lights all fourteen segments, she reruns the converter with that byte: the total becomes 14 × 9.1 = 127 mA, still under the 200 mA ceiling, though close enough that she will measure it on the bench.
Seven Segment Display Decoder Logic with K-Maps
A seven segment display decoder is a combinational logic circuit, so each output is a Boolean function of the four inputs. Designers minimise those functions with a Karnaugh map, one K-map per segment, and then build them from logic gates. Rows 10 to 15 are usually treated as don’t-care conditions in a pure BCD design, but in a hex design they get real patterns and the equations grow slightly.
In digital logic terms, each segment column of the truth table above is one K-map, with the four hex bits as its variables. The course material behind this topic starts with the number system and base conversions, then moves through Boolean algebra to code converters. A display decoder is the most visible example, because its result can be seen on a clock face.
7-Segment Encoder, Decoder and Cipher Uses
A 7-segment encoder runs the other direction: it takes a set of lit segments and returns the character. Puzzle writers use that idea as a simple symbol-substitution cipher. To decrypt such a cipher you read the letters a to g in each group, light those segments and read the digit, and to encrypt you do the reverse. A group of up to seven letters with no repeats, or a 7-bit binary string, is the usual sign that you are looking at a 7-segment decoder puzzle.
Larger segment counts
There are also 9 segment displays with two extra diagonals, parts with 14 segments that add a central vertical bar, and parts with 16 segments whose top and bottom bars are split in half. They show full letters, but they need wider codes than the 7-bit hex pattern and a different decoder. Parts like these became widespread in the 1970s.
Where a 7 Segment Decoder Shows Up
- Clocks, watches and counters: a digital watch or one of the many alarm clocks counts in BCD, so only the digits 0 to 9 of the hex table, patterns 3F through 6F, are ever needed.
- Calculator displays: calculators turn stored numbers into one cathode or anode byte per result digit, the same byte this converter returns, and shifts it out to the screen.
- Voltmeters and ammeters: bench instruments convert a measured value into a numeric readout.
- POST cards and debug ports: two hex digits display a boot code so you can see where a machine stopped.
Each of these is an electronics project where the same hex patterns repeat, which is why a quick converter beats redrawing the segment map every time. Hobbyists also rely on the same tables when they test a salvaged module, because lighting one digit at a time, with every illuminated segment checked by eye, shows quickly whether a segment is open, shorted or wired to the wrong pin. Students use them to check homework, and engineers use them to review a state machine’s output before any hardware exists.
How to Use the Hex to 7 Segment Display Decoder Step by Step
- Enter one or more hex digits, from 0 to F.
- Pick common cathode or common anode so the converter knows the polarity of your part.
- Click the Convert button to see the lit segments, the 7-bit pattern, the hex byte and the decimal value.
- Copy the byte or the binary string into your port register, lookup table or HDL file.
- Check the result against the truth table above if the display looks wrong.
If a digit shows up garbled, the usual cause is a polarity mismatch or a swapped segment pin. Compare the pin order of your part with the a to g order the converter uses, then try the opposite polarity before looking at the code.