> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/wokwi/wokwi-docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 7-Segment Display

> Seven segment LED display with configurable digits and colors

Seven segment LED display

## Pin names

<ParamField path="A" type="pin">
  Top segment
</ParamField>

<ParamField path="B" type="pin">
  Top-right segment
</ParamField>

<ParamField path="C" type="pin">
  Bottom-right segment
</ParamField>

<ParamField path="D" type="pin">
  Bottom segment
</ParamField>

<ParamField path="E" type="pin">
  Bottom-left segment
</ParamField>

<ParamField path="F" type="pin">
  Top-left segment
</ParamField>

<ParamField path="G" type="pin">
  Middle segment
</ParamField>

<ParamField path="DP" type="pin">
  Dot LED
</ParamField>

<ParamField path="COM" type="pin">
  Common pin (for single digit displays)
</ParamField>

<ParamField path="DIG1" type="pin">
  Digit 1 pin (for multi-digit displays)
</ParamField>

<ParamField path="DIG2" type="pin">
  Digit 2 pin (for multi-digit displays)
</ParamField>

<ParamField path="DIG3" type="pin">
  Digit 3 pin (for multi-digit displays)
</ParamField>

<ParamField path="DIG4" type="pin">
  Digit 4 pin (for multi-digit displays)
</ParamField>

<ParamField path="CLN" type="pin">
  Colon pin (optional, for clock mode)
</ParamField>

<Note>
  COM is the common pin for a single digit 7-segment display. For multi digit displays, use DIG1…DIG4.
</Note>

With the default `common` attribute setting of `anode`, the segment pins (A…G, DP, CLN) are connected to the cathode (negative side) of the LEDS, and the common pins (COM, DIG1…DIG4) are connected to the anode (positive side) of the LEDs. Segments are lit by driving their pins low. Setting `common` to `cathode` reverses this behavior, with the segment pins turning on when high.

## Attributes

<ParamField path="common" type="string" default="anode">
  The common pin configuration: "cathode" or "anode"
</ParamField>

<ParamField path="digits" type="string" default="1">
  Number of digits: "1", "2", "3" or "4"
</ParamField>

<ParamField path="colon" type="string" default="">
  Set to "1" to show the colon (clock mode)
</ParamField>

<ParamField path="color" type="string" default="red">
  The color of the segment LEDs
</ParamField>

## Using the 7-segment display

For a single digit, you'll need 8 microcontroller GPIO pins. Each pin should be connected to a single segment through a resistor, and the common pin should be connected to 5V (or GND if you are using the common cathode variant). You can spare one pin (DP) if you don't use the dot LED. Turn a segment on by driving the corresponding segment on (or HIGH for the common cathode variant).

For multiple digits, you'll need 8 microcontroller pins for the segments and the dot plus one extra microcontroller pin for each digit. So if you have 4 digits, you'll need 12 microcontroller pins in total. Controlling the display in this mode is a bit tricky, as you'll need to continuously alternate between the different digits.

Luckily, there are libraries that can help:

* On Arduino: Use the [SevSeg library](https://wokwi.com/projects/344891439152366164).
* On the Raspberry Pi Pico: The PIO peripheral can take care of refreshing the display for you. See the examples below.

If you are out of microcontroller pins, consider using a [74HC595 Shift Register](wokwi-74hc595) to drive the display.

## Simulator examples

* [SevSeg example: Counter](https://wokwi.com/projects/344891439152366164)
* [SevSeg example: String with period](https://wokwi.com/projects/344893935754150484)
* [Arduino alarm clock](https://wokwi.com/projects/297787059514376717)
* [Static versus multiplexed signals for 7-segment displays](https://wokwi.com/projects/397598198000164865)
* [ATtiny85 7-segment clock](https://wokwi.com/projects/301366580039647753)
* [ATtiny85 8 digit counter](https://wokwi.com/projects/301304715310793225)
* [7-segment on the Raspberry Pi Pico (using PIO)](https://wokwi.com/projects/301404853501952521)
* [7-segment on the Raspberry Pi Pico (MicroPython)](https://wokwi.com/projects/300936948537623048)
