Arduino SevSeg 7-Segment Library: Wiring, Code and Simulator

To build this Arduino SevSeg 7-Segment Library project you need an Arduino Uno and a 7-segment display. The SevSeg library shows a number on a common-cathode 7-segment display. Make the 9 connections in the wiring table, upload the Arduino C++ code, and change setNumber(7) to another digit.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board
17-segment displayOne digit. Segments A–G and DP share COM (common cathode by default).

Wiring

#FromTo
1Arduino Uno pin 27-segment display A
2Arduino Uno pin 37-segment display B
3Arduino Uno pin 47-segment display C
4Arduino Uno pin 57-segment display D
5Arduino Uno pin 67-segment display E
6Arduino Uno pin 77-segment display F
7Arduino Uno pin 87-segment display G
8Arduino Uno pin 107-segment display DP
9Arduino Uno pin 97-segment display COM

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a 7-segment display from the parts palette.
  3. Wire 1. Connect Arduino Uno pin 2 to 7-segment display A.
  4. Wire 2. Connect Arduino Uno pin 3 to 7-segment display B.
  5. Wire 3. Connect Arduino Uno pin 4 to 7-segment display C.
  6. Wire 4. Connect Arduino Uno pin 5 to 7-segment display D.
  7. Wire 5. Connect Arduino Uno pin 6 to 7-segment display E.
  8. Wire 6. Connect Arduino Uno pin 7 to 7-segment display F.
  9. Wire 7. Connect Arduino Uno pin 8 to 7-segment display G.
  10. Wire 8. Connect Arduino Uno pin 10 to 7-segment display DP.
  11. Wire 9. Connect Arduino Uno pin 9 to 7-segment display COM.
  12. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  13. Run it. Press Run. Change setNumber(7) to another digit.

Arduino C++ code

// SevSeg: show a digit on a common-cathode 7-segment display (segments on 2-8).
#include <SevSeg.h>

SevSeg seg;

void setup() {
  byte digitPins[] = {9};
  byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8, 10};
  seg.begin(COMMON_CATHODE, 1, digitPins, segmentPins, true);
  seg.setNumber(7);
}

void loop() {
  seg.refreshDisplay();
}

What to try

Change setNumber(7) to another digit.

Frequently asked questions

How do I wire the SevSeg 7-Segment Library project on an Arduino Uno?

Make 9 connections: Arduino Uno pin 2 to 7-segment display A; Arduino Uno pin 3 to 7-segment display B; Arduino Uno pin 4 to 7-segment display C; Arduino Uno pin 5 to 7-segment display D; Arduino Uno pin 6 to 7-segment display E; Arduino Uno pin 7 to 7-segment display F; Arduino Uno pin 8 to 7-segment display G; Arduino Uno pin 10 to 7-segment display DP; Arduino Uno pin 9 to 7-segment display COM.

What parts do I need for this Arduino project?

An Arduino Uno and a 7-segment display.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

The SevSeg library shows a number on a common-cathode 7-segment display.

More Arduino Uno projects