Seven-Segment Display Encoder

Design any 7-segment character by tapping segments and get its byte in hex and binary for common cathode or anode, plus a ready Arduino array.

  • Free, no signup
  • Works on mobile
  • Formula + worked example

How to use the seven-segment encoder

  1. Tap the segments on the digit (or the a–g and dp buttons) to draw a character. The quick buttons load 0–9, A–F and useful extras such as -, H, L, P, U and °.
  2. Choose your display type — common cathode or common anode — and the bit order your code or wiring uses.
  3. Read the byte in hex, binary and decimal for both display types. The bit map shows exactly which segment sits on which bit.
  4. Copy the Arduino array. It contains 0–F plus your own character, already in the format you chose.

Already have a byte from someone else's code? Type it into Decode a byte (for example 0x5B, 0b01011011 or 91) and the digit shows what it draws.

Segment names

Every seven-segment display uses the same letters. a is the top bar, then b, c, d, e, f go clockwise around the digit, g is the middle bar and dp is the decimal point.

SegmentPositionBit (dp…a order)Bit (a…dp order)
atop07
bupper right16
clower right25
dbottom34
elower left43
fupper left52
gmiddle61
dpdecimal point70

Formula

Each lit segment adds its bit's value to the byte. For a common-cathode display, a 1 lights the segment. A common-anode display is the exact opposite, so you invert every bit:

CC byte = Σ 2^bit for every lit segment CA byte = 255 − CC byte (same as ~CC & 0xFF)

Common cathode or common anode?

In a common-cathode display all the LED cathodes (−) are joined to one COM pin, which goes to GND; you drive a segment HIGH to light it. In a common-anode display all the anodes (+) are joined and COM goes to Vcc; you pull a segment LOW to light it. If your digits look like "photo negatives" — everything lit except what you wanted — you have the other type. Check with a multimeter in diode mode, or select the other type here.

Common mistakes

  • Mixing bit orders. A table copied from a website may use a…dp order while your wiring assumes dp…a. The digit then shows scrambled segments. Pick the order once and use it everywhere.
  • Forgetting dp. Many tables leave bit 7 as 0. To light the decimal point, add 0x80 (dp…a order, common cathode).
  • Assuming the pinout. Pin numbers differ between display models. Check which pin is a, b, c… with a 3 V coin cell and a resistor before soldering.
  • Overloading the microcontroller. Eight segments at 15 mA each is 120 mA. Check your board's total current limit, or drive the segments through a driver IC.

Convert bytes between bases with the programmer's base converter, explore Boolean logic with the logic gate truth table, or mix colours with the RGB LED colour mixer. Choosing a board for your display project? Read Arduino vs ESP32 vs Raspberry Pi Pico, and browse our kits.

Frequently asked questions

What are the 7-segment codes for 0 to 9?+

For a common-cathode display with bit order dp g f e d c b a: 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F. For common anode, invert every bit: 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90.

What is the difference between common cathode and common anode?+

In a common-cathode display all segment cathodes share one pin connected to GND, and a HIGH signal lights a segment. In a common-anode display all anodes share one pin connected to Vcc, and a LOW signal lights a segment. Their codes are bit-inverses of each other.

How do I know if my display is common cathode or common anode?+

Set a multimeter to diode mode. Put the black probe on a COM pin and the red probe on a segment pin: if the segment glows, it is common cathode. If it only glows with the probes swapped, it is common anode.

Why does my 7-segment display show the wrong segments?+

The bit order in your code does not match your wiring, or you are using common-cathode codes on a common-anode display. Choose the matching bit order and display type in this tool and copy the new array.

How do I light the decimal point?+

The decimal point is the eighth bit. In dp g f e d c b a order on a common-cathode display, add 0x80 to the code — for example 0x06 (1) becomes 0x86 (1.). On common anode, clear that bit instead.

From the Thinking Robot store

Shop all
All tools
WhatsApp