Using a 4 Digit, 7 Segment Display, With Arduino





Introduction: Using a 4 Digit, 7 Segment Display, With Arduino

In this tutorial I will be showing you how to use a 7 segment display with 4 digits using arduino. Some basic things I would like to point out is that this takes up almost all of the digital pins on the arduino uno, leonardo, the boards with 13 digital pins. Most displays have 12 breakout pins that connect either directly to the arduino, or through a resistor. Also, I would like to point out that these displays have no need for Ground, 5V, or 3.3V to be connected. So, let's get started...

Step 1: Materials

Using a display of this kind requires almost no materials.

- 4 x 330Ω resistors

- 12 x Male to male jumper wires

- 1 x Arduino

- 1 x breadboard of any size (they don't need the power rails)

No tools are required in order to make a prototype of this design. However, a soldering iron and a pcb board would be needed for a more permanent use.

Step 2: Breadboard Layout

Just to give you some context i will explain the usage of each pin. 8 out of the 12 pins on the display are used for the 8 segments. There are 7 segments used to form any digit while one controls the decimal point. The other 4 out of the 12 pins control each of the 4 digits on the display. Any pin that has a resistor on it is one of the 4 digit pins, otherwise they are the segment pins.

The above design I created from fritzing in order to show the connection between the display and the arduino. Note the placement of where the resistors are because if you connect the resistor to the wrong pin on the display, either that digit will not work or that segment will not work, FOREVER...


When setting up the circuit switch the yellow and the purple wires (I messed up my circuit diagram).

Step 3: Installing the Library

The library linked below is from the arduino website for easily controlling a display. The link goes to github. If you have never been on github listen carefully, if you have read the next paragraph. When you get onto the website look at the right side of the window and look down until you see, "Download Zip". Click that button and watch it appear in your downloads.

Now you have to load the previously installed library into your libraries folder. If you now how to do this then skip to the next step, otherwise keep on reading. First go into finder and locate the "documents" folder, and open it. Then, locate the "arduino" folder, and open it. Then, locate the libraries folder, and open it. Finally drag and drop the installed library into the just opened libraries folder.

IMPORTANT. If your arduino application was opened and running while you where putting the library into the libraries folder, the arduino won't recognize the library. You just have to quit the application and open it again.

Step 4: The Code

The code for actually displaying something is listed below.

#include "SevSeg.h"

SevSeg sevseg; //Initiate a seven segment controller object

void setup() {

byte numDigits = 4;

byte digitPins[] = {2, 3, 4, 5};

byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};

sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);



void loop() {

sevseg.setNumber(3141, 3);

sevseg.refreshDisplay(); // Must run repeatedly


Step 5: The Result

If you connected the display correctly, uploaded the code correctly, and copied the coded just right, then your display should be displaying pi (only 3.141).

If not then, read step six for whatever is happening wrong.

If you did get it right, then I suggest reading going further in step seven.

Step 6: Troubleshooting

Here i have listed two possible things that could have happend to your display that could have messed it up. Sadly only one of the two is fixable.

- Your display is displaying 8888

Do not worry this is the problem that is fixable, just follow these steps

1. Locate in the code " sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins); "


3. Upload the code again

- Your display is displaying 3. 41 or .141 or 3.1 1 or 3.14 without the other 1

Sadly, this problem can either be fixable or not :.(... (thats my crying face)

1. Check your connections and make sure everything IS plugged in and not hanging out

2. Check the schematic again, because you most likely plugged it in wrong

3. Locate the line in void loop where it says to display (3.141, 3) and change 3.141 to 8888 and see if one of the 8 are missing

4. If so one of the wires might have not had a resistor when it should have had one meaning that one of the digits had burned out. You can check this by looking at the back of the display. If you see any black near one of the pins you did overpower one of the digit places. Sadly this IS NOT fixable and you would want to buy another display.

5. If you do not see a black mark anywhere than you switched up wires that can't get overpowered so check the schematic and plug then in correctly and change the code back from 8888 to 3.141.

Step 7: Going Further

One method of using a few pins on the arduino to control multiple LEDs that would otherwise require alot of pin is a tri-state 8 pin shift-register. So instead of directly connecting the 8 segment pins to arduino you can plug them into the shift register and figure out how to do that.

It is just an idea that I came up with but I do not know how to do or if it is even possible with the arduino and the display's library, but hey, food for thought for the curious.

Have fun with your display and i hope you liked this instructable because it is the first that i have actually finished out of the many i have in my drafts.

13 People Made This Project!


  • Remote Control Contest 2017

    Remote Control Contest 2017
  • Arduino Contest 2017

    Arduino Contest 2017
  • LED Contest 2017

    LED Contest 2017

We have a be nice policy.
Please be positive and constructive.


Questions & Answers


Thanks for this starter, this will go in a toy microwave for my daughter's play kitchen, together with a salvaged speaker (DECT phone I think) for the beeps (ToneMelody), some buttons from a Sudoku game, a TT motor for the dish and some LEDs for the light.

Thanks. I had the same issue as FritsBee 3461BS4 digit 7 segment display with a common anode. I was working on a clock a while back but couldn't get the display working. I found this instructable today and thought I would start with it and then build on it.

I made it but there is a simple problem

The middel and the topleft LED's are switched.

I replaced the text 3141 to 0000

And the answer is at the picture.

What did I do wrong?

I doubble checked all the wires.

I change the text the the standard 3141 and this what I get.

I seems that only the 0 has problems.. :-(

It seems some of the displays have a couple of pins swapped. If your 0, 2, 3, etc. look funky...try changing this line in the code:

byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};

byte segmentPins[] = {6, 7, 8, 9, 10, 12, 11, 13};

It seems some of the displays have a couple of pins swapped. If your 0, 2, 3, etc. look funky...try changing this line in the code:

byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};

byte segmentPins[] = {6, 7, 8, 9, 10, 12, 11, 13};

Using 47 ohm resistors.

#include "SevSeg.h"

SevSeg sevseg;

unsigned long milliseconds;

unsigned long num = 0;

void setup() {

// put your setup code here, to run once:

byte numDigits=4;

byte digitPins[] = {2,3,4,5};

byte segmentPins[] = {6,7,8,9,10,11,12,13};




void loop() {

// put your main code here, to run repeatedly:

num = num/1000;



milliseconds = millis();

num = milliseconds % 10000000; // Rollover to 0 at 9999


AFAIS you use one 330E resistor per digit for current limiting. As you can have 0-8 LEDs per digit, I expect the brightnes of that digit will highly depend of the number of active LEDs required for that digit. The resistor will limit the current to about 10mA so if only the decimal point is active, it will have the whole 10mA. If all LEDS are active, each one will get only a 1.22mA. Much less current so much less light or is there some kind of compensation somewhere?

Only 1 segment per digit is on at any given time. This is very easy to see if you add a delay(100) between the setNumber and refreshDisplay calls. It is iterating over every segment and relies on persistance of vision.