Summary
A 7 segment display has seven LED segments (a to g) and a decimal point on 10 pins, with pins 3 and 8 as common. This guide covers the labelled pinout, common anode vs common cathode truth tables, a multimeter test to identify your display, resistor wiring, and Arduino code that counts 0 to 9.

A 7 segment display has seven LED segments (a to g) and a decimal point (DP) on 10 pins, with pins 3 and 8 as the common pins. In a common anode display, the common connects to VCC and a segment lights on LOW. In a common cathode display, the common connects to GND and a segment lights on HIGH.
In this post, we look at the 7 segment display pin diagram, compare common anode and common cathode types, test a display with a multimeter to find out which one you have, and write Arduino code that counts from 0 to 9.
What Is a 7 Segment Display?
A 7 segment display is a package of seven bar-shaped LEDs arranged in the shape of the number 8. By switching different segments on and off, it can show any digit from 0 to 9 and a few letters such as A, b, C, d, E and F.
The segments are named a to g, going clockwise from the top bar, with g as the middle bar. Most displays also have an eighth LED, the decimal point (DP), at the bottom right.
7 Segment Display Working
Each segment is a normal LED with an anode (+) and a cathode (−). To save pins, the manufacturer joins one side of all eight LEDs together inside the package. This shared connection is called the common pin.
- If all the anodes are joined, it is a common anode display.
- If all the cathodes are joined, it is a common cathode display.
The other end of each LED comes out on its own pin. You light a segment by completing the circuit through that pin, so the display only needs 8 control lines plus the common, instead of 16 separate wires.
For example, to show the digit 1, you turn on segments b and c only. To show 8, you turn on all seven.
Components and Supplies
7 Segment Display Pin Diagram
The standard single-digit 7 segment display (the 0.56 inch type used in most Arduino projects) has 10 pins in two rows of five. Hold the display facing you with the decimal point at the bottom right. Pin 1 is at the bottom left, and the numbering runs anticlockwise.

The pinout is the same for common anode and common cathode displays. Only the job of the common pins changes.
| Pin | Function | What it controls |
|---|---|---|
| 1 | e | Bottom-left segment |
| 2 | d | Bottom segment |
| 3 | COM | Common anode or common cathode |
| 4 | c | Bottom-right segment |
| 5 | DP | Decimal point |
| 6 | b | Top-right segment |
| 7 | a | Top segment |
| 8 | COM | Common anode or common cathode |
| 9 | f | Top-left segment |
| 10 | g | Middle segment |
Pins 3 and 8 are connected to each other inside the package, so you only need to wire one of them. Using both is fine and spreads the current across two pins.
Robocraze tip: Most single-digit displays follow this pinout, but some sizes and brands do not. If your display behaves strangely, run the multimeter test below to confirm each pin before soldering.
Common Anode vs Common Cathode
The only difference between the two types is which end of the LEDs is joined together. This one detail decides where the common pin goes and whether a segment turns on with HIGH or LOW.

A common anode display will not light at all if you wire it like a common cathode one, because every LED is reverse biased. Nothing gets damaged, but nothing glows either. This is the most common reason a new 7 segment circuit "does nothing".
| Feature | Common Anode (CA) | Common Cathode (CC) |
|---|---|---|
| Joined inside | All anodes (+) | All cathodes (−) |
| Common pin (3, 8) connects to | VCC (5V on Arduino Uno) | GND |
| Segment turns ON when its pin is | LOW (0V) | HIGH (5V) |
| Segment turns OFF when its pin is | HIGH | LOW |
| Arduino pin role | Sinks current | Sources current |
| Code logic | Inverted (0 = ON) | Direct (1 = ON) |
| Matching BCD decoder IC | 74LS47 / 7447 (active-low outputs) | CD4511, 74LS48 (active-high outputs) |
| Best for | Logic ICs that sink current better than they source | Beginners, because HIGH = ON reads naturally in code |
Shop the displays used in this guide
| Product | Pick it if |
|---|---|
| 7 Segment LED Display (Common Anode) | You are using a 74LS47 decoder or want the Arduino to sink current |
| 7 Segment LED Display (Common Cathode) | You want the simplest Arduino code, where HIGH lights a segment |
Truth Table: Common Cathode (1 = segment ON)
The hex code packs segments a to g into one byte, with a as bit 0 and g as bit 6. It is handy when you drive the display from a shift register.
| Digit | a | b | c | d | e | f | g | Hex |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0x3F |
| 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0x06 |
| 2 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 0x5B |
| 3 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0x4F |
| 4 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0x66 |
| 5 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0x6D |
| 6 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0x7D |
| 7 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0x07 |
| 8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0x7F |
| 9 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0x6F |
Truth Table: Common Anode (0 = segment ON)
Every bit is simply flipped. If you already have the common cathode pattern, invert it and you get the common anode one.
| Digit | a | b | c | d | e | f | g | Hex |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0x40 |
| 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0x79 |
| 2 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0x24 |
| 3 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0x30 |
| 4 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0x19 |
| 5 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0x12 |
| 6 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0x02 |
| 7 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0x78 |
| 8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0x00 |
| 9 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0x10 |
How to Identify Common Anode or Common Cathode With a Multimeter
Both types look identical from the outside, and the part number is often missing or rubbed off. The quickest way to tell them apart is the diode test mode on a digital multimeter. It takes under a minute and also confirms your pinout.
In diode mode, the meter pushes a small current out of the red probe (+) and back into the black probe (−). An LED only conducts in the forward direction, so a segment glows only when the red probe is on its anode and the black probe is on its cathode.
What you need: a digital multimeter with a diode test setting (the ▶| symbol) and the display itself. If you are new to meters, read our guide on how to read a multimeter first.
Step-by-step test
- Set the dial to diode test. Black lead in COM, red lead in V/Ω. Touch the probes together; the display should read close to 0.
- Confirm the common pins. Touch one probe to pin 3 and the other to pin 8. A reading near 0 (or a beep) means they are joined inside, so these are your common pins.
- Test for common anode. Put the red probe on pin 3 and the black probe on pin 7 (segment a). If segment a glows faintly and the meter shows roughly 1.6V to 2.0V, the display is common anode.
- Test for common cathode. If nothing happened, swap the probes: black on pin 3, red on pin 7. If segment a now glows, the display is common cathode.
- Map every segment. Keep the probe that worked on the common pin and touch each remaining pin in turn. Note which segment lights for each pin number. If your notes match the pin table above, you have a standard pinout.
| Red probe | Black probe | Segment a glows? | Result |
|---|---|---|---|
| Pin 3 (COM) | Pin 7 (a) | Yes | Common anode |
| Pin 7 (a) | Pin 3 (COM) | Yes | Common cathode |
| Either way | Either way | No, OL both ways | Pin 3 is not common on this display; repeat with pin 8, then check the datasheet |
Tips for if the segment does not glow
- Shade the display with your hand. The glow from a meter's test current is faint, especially under bright lights.
- Check the colour. A red display needs about 1.8V to light. Blue and white displays need about 3V, which some low-cost meters cannot supply. The meter will show OL even though the display is fine.
- Check the reading, not just the glow. A reading of 1.5V to 2.0V in one direction and OL in the other proves the LED is there and working.
No multimeter? Use the Arduino's 5V pin
Connect the Arduino 5V pin through a 330Ω resistor to pin 3, and touch pin 7 to GND. If segment a lights, the display is common anode. If not, swap the two wires (5V through the resistor to pin 7, pin 3 to GND). If it lights now, it is common cathode.
Never connect a segment straight to 5V without the resistor, even for a quick test. The LED can burn out instantly.
Wiring a 7 Segment Display to Arduino With Resistors
The wiring uses eight Arduino digital pins, D2 to D9, one for each segment and the decimal point. The common pin goes to GND for a common cathode display or to 5V for a common anode display. Everything else stays the same.
Hardware Required
- Arduino Uno or any compatible board - 1
- 7 segment display (common anode or common cathode) - 1
- 220Ω to 330Ω resistors - 8
- Breadboard - 1
- Jumper wires - as required

| Display pin | Segment | Arduino pin |
|---|---|---|
| 7 | a | D2 |
| 6 | b | D3 |
| 4 | c | D4 |
| 2 | d | D5 |
| 1 | e | D6 |
| 9 | f | D7 |
| 10 | g | D8 |
| 5 | DP | D9 |
| 3 or 8 | COM | GND (common cathode) or 5V (common anode) |
If you need a refresher on where D2 to D9 sit on the board, see our Arduino Uno pin diagram guide.
Every segment needs its own resistor
Put one 220Ω to 330Ω resistor in series with each segment pin, not a single resistor on the common pin.
Each segment is an LED, and an LED needs current limiting, exactly as in our LED interfacing with Arduino tutorial. If you use one resistor on COM, all the lit segments share that one current. The digit 1 (two segments) will look bright and the digit 8 (seven segments) will look dim. Separate resistors give every segment the same brightness, whatever digit is on screen.
Here is the quick maths for a red display with a forward voltage of about 2V:
- 220Ω: (5V − 2V) ÷ 220Ω ≈ 14mA per segment. Bright and safe.
- 330Ω: (5V − 2V) ÷ 330Ω ≈ 9mA per segment. Slightly dimmer, easier on the board.
With all eight LEDs on at 220Ω, the common pin carries about 110mA. That is within what the Uno's 5V and GND pins can handle for a single digit. For the colour codes and resistor types, see types of resistors in electronics.
Arduino Code: Count 0 to 9
This sketch counts from 0 to 9 with a one-second gap, then starts again. It works with both display types. Change one line at the top to match your display and upload.
// 7 Segment Display: Count 0 to 9
// Works with common anode and common cathode displays
// Set to true for a COMMON ANODE display, false for COMMON CATHODE
const bool COMMON_ANODE = false;
// Arduino pins for segments a, b, c, d, e, f, g and DP
const int segmentPins[8] = {2, 3, 4, 5, 6, 7, 8, 9};
// Segment patterns for digits 0-9 (1 = segment ON)
// Order: a, b, c, d, e, f, g
const byte digitPatterns[10][7] = {
{1, 1, 1, 1, 1, 1, 0}, // 0
{0, 1, 1, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1}, // 2
{1, 1, 1, 1, 0, 0, 1}, // 3
{0, 1, 1, 0, 0, 1, 1}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 0, 1, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1}, // 8
{1, 1, 1, 1, 0, 1, 1} // 9
};
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(segmentPins[i], OUTPUT);
}
setSegment(7, false); // keep the decimal point off
}
void loop() {
for (int digit = 0; digit <= 9; digit++) {
showDigit(digit);
delay(1000);
}
}
// Turn one segment ON or OFF, handling the display type
void setSegment(int segment, bool on) {
if (COMMON_ANODE) {
on = !on; // common anode: LOW lights the segment
}
digitalWrite(segmentPins[segment], on ? HIGH : LOW);
}
// Show a digit from 0 to 9
void showDigit(int digit) {
for (int s = 0; s < 7; s++) {
setSegment(s, digitPatterns[digit][s]);
}
}
Code Explanation
-
const bool COMMON_ANODE = false;: This is the only line you need to change. Set it totruefor a common anode display andfalsefor a common cathode display. -
segmentPins[8]: Stores the Arduino pin for each segment in the order a, b, c, d, e, f, g, DP. If you wire the display differently, change the numbers here and nothing else. -
digitPatterns[10][7]: This is the common cathode truth table from earlier, written as a 2D array. Each row is one digit, and each 1 means that segment should light. -
setup(): Runs once. It sets all eight pins as outputs and turns the decimal point off. -
loop(): Runs forever. It callsshowDigit()for 0 to 9, waiting 1000 milliseconds (1 second) after each digit. -
setSegment(): Does the actual switching. For a common anode display, it flips the value withon = !on, so a segment that should be ON gets a LOW signal. This is how one sketch handles both types. -
showDigit(): Reads one row ofdigitPatternsand sends each of the seven values tosetSegment().
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| Nothing lights at all | COM wired to the wrong rail for your type | CC: COM to GND. CA: COM to 5V. Re-run the multimeter test if unsure. |
| Shows the opposite of each digit (8 looks like a blank, 1 shows everything but b and c) | COMMON_ANODE set wrong | Flip it between true and false and upload again |
| Digits look scrambled | Segment wires swapped | Check each wire against the wiring table, especially pins 6, 7, 9 and 10 |
| Some segments are dimmer than others | Mixed resistor values or a shared resistor on COM | Use the same 220Ω to 330Ω value on every segment pin |
Driving It With a 74HC595 or BCD to 7 Segment Decoder
The direct method uses 8 Arduino pins for one digit. That is fine for a single display, but it gets expensive fast. Two chips solve this.
74HC595 shift register (3 Arduino pins)
The 74HC595 takes data one bit at a time over 3 pins (data, clock and latch) and sets 8 outputs at once. Wire outputs Q0 to Q6 to segments a to g and Q7 to DP, each through its own 220Ω resistor. Then send the hex codes from the truth tables above:
const int dataPin = 11, clockPin = 12, latchPin = 10;
const byte digitCodes[10] = {0x3F, 0x06, 0x5B, 0x4F, 0x66,
0x6D, 0x7D, 0x07, 0x7F, 0x6F}; // common cathode
void showDigit(int d) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digitCodes[d]); // use ~digitCodes[d] for common anode
digitalWrite(latchPin, HIGH);
}
Remember to set all three pins as OUTPUT in setup(). Wire Arduino pin 11 to the 74HC595 DS pin (14), pin 12 to SH_CP (11) and pin 10 to ST_CP (12).
BCD to 7 segment decoder (4 Arduino pins, no lookup table)
A BCD to 7 segment decoder takes a 4-bit binary number (0000 to 1001) on inputs A, B, C and D and lights the right segments by itself. Your code only sends the number, and the chip handles the truth table. Pick the decoder that matches your display type:
| Decoder IC | Output type | Use with |
|---|---|---|
| 74LS47 / 7447 | Active LOW | Common anode |
| CD4511 | Active HIGH, with built-in latch | Common cathode |
| 74LS48 | Active HIGH | Common cathode |
You still need one resistor between each decoder output and its segment. Decoders do not control the decimal point, so wire DP to a spare Arduino pin if you need it.
Conclusion
Once you know the 7 segment display pin diagram, the rest is simple. Pins 3 and 8 are common, the other eight pins each drive one LED, and the only thing that changes between types is where COM goes and whether HIGH or LOW lights a segment. Test the display with a multimeter before you wire it, give every segment its own resistor, and set one line in the code to match your display.
From here, you can move on to multi-digit counters, clocks and scoreboards. See 4-digit and module versions in our 7 segment collection.






