Learn
Lighting a Single-Digit 7-Segment Display (Common-Cathode) on a Raspberry Pi 4B
Wire a common-cathode 7-segment display to a Raspberry Pi 4B, drive each of its 8 segments independently from its own GPIO pin, and light an arbitrary pattern — no digit lookup involved, so the exact same wiring is ready for a later 74HC595 shift-register project.
Note: the Single-Digit 7-Segment Display (Common-Cathode) is a VIP-tier component in the simulator — you’ll need a VIP plan to use it there.
Try this directly in the free Raspberry Pi 4B simulator — no hardware or signup required. New to the GPIO header? Start with the interactive pinout guide.
What you’ll need
- Raspberry Pi 4B
- Single-Digit 7-Segment Display (Common-Cathode)
- 8 Resistors
Step by step
- Drag Raspberry Pi 4B onto the Canvas.
- Drag the Single-Digit 7-Segment Display onto the Canvas — a real 10-pin DIP package. It mounts straight into a breadboard spanning the center gap, the same way the MCP3008 does, or wires directly to the Pi.
- Hover its pins to confirm the labels. Bottom edge, left to right: E, D, COM, C, DP. Top edge, left to right: G, F, COM, A, B — the two COM pins sit in the same column, on opposite edges, and are internally tied together (wiring GND to either one grounds both).
| Segment | What it lights |
|---|---|
| A | top |
| B | top-right |
| C | bottom-right |
| D | bottom |
| E | bottom-left |
| F | top-left |
| G | middle |
| DP | decimal point |
- Wire either COM pin → a Pi GND pin — this is the shared cathode for all 8 segments.
- Wire each of the 8 segment pins (A-G, DP) → its own Resistor → its own Pi GPIO pin, exactly the same series-resistor treatment a plain LED needs. Each segment is electrically independent — there's no shared anode, so any combination can light at once.
- Go to the Code tab and write a script that lights an arbitrary pattern — not a real digit:
import RPi.GPIO as GPIOimport asyncio GPIO.setmode(GPIO.BOARD)# adjust these to match your wiringSEG_A, SEG_C, SEG_F, SEG_DP = 37, 38, 40, 36 for pin in (SEG_A, SEG_C, SEG_F, SEG_DP): GPIO.setup(pin, GPIO.OUT) while True: GPIO.output(SEG_A, GPIO.HIGH) GPIO.output(SEG_C, GPIO.HIGH) GPIO.output(SEG_F, GPIO.HIGH) GPIO.output(SEG_DP, GPIO.HIGH) print("A + C + F + DP lit — not a real digit shape") await asyncio.sleep(2) GPIO.output(SEG_A, GPIO.LOW) GPIO.output(SEG_C, GPIO.LOW) GPIO.output(SEG_F, GPIO.LOW) GPIO.output(SEG_DP, GPIO.LOW) await asyncio.sleep(2)- Click Start.
There's deliberately no digit-lookup table anywhere in this simulator — each segment reacts purely to its own pin's HIGH/LOW state, the same way 8 completely independent LEDs would. That's exactly what makes this component ready to pair with a 74HC595 shift register later: the shift register just drives each of these 8 pins bit-by-bit, and the display doesn't need to know or care what "digit" that pattern happens to represent.
What “working correctly” looks like
- Each segment lights independently the instant its own pin goes HIGH — driving only A and G, for example, lights just those two strokes, not a recognizable digit.
- Wiring GND to only ONE of the two COM pins still correctly grounds every segment — the two commons are internally tied together on this component, matching the real hardware (they're the same physical node, split into two pins purely for the package's own mechanical layout).
- A resistor value that's too low logs the same low-series-resistance advisory a plain LED gets, scoped to whichever lit segment currently has the least series resistance.
- The reference script above lights A, C, F, and DP together — a pattern that doesn't correspond to any real digit — confirming there's no hidden digit lookup silently "correcting" your wiring.
If something’s wrong
- A segment never lights → confirm that segment's own pin is wired through a resistor to a Pi GPIO pin your script actually drives HIGH, and confirm at least one COM pin reaches a real Pi GND pin.
- One segment stays permanently dim or dark while others work → check that segment's own resistor value; a disconnected or extremely high-value resistor starves that one segment of current.
- You expected a real digit shape and got something else → this component has no digit-to-segment lookup at all; double-check which physical segment (A-G, DP) each of your wires actually lands on, using the pin table above.