7 segment display and Arduino

7 segment display

A display is a small screen with segments that are illuminated by LEDs to show some information. That is why they are very useful to show some type of data, such as a count of a counter, the value collected by a sensor in decimal, etc. As you already know, this kind of 7 segment display it can form numbers and letters, as well as some symbols. Although it is quite limited.

There are others displays of more segments that can form more complex alphanumeric characters or symbols. You can also combine several of these 7-segment displays to show more figures or amount of information. In fact, they already sell modules with several of these simple displays attached to create a somewhat larger panel, such as modules that use four 7-segment displays, etc.

7-segment display and pinout operation

form characters on 7-segment display

It is quite simple, it is a panel with some lines that are illuminated by an LED. Depending on the lines that light up, a different character may be represented. To carry out this control, there are 10 pins for each 7-segment display. One for each segment, the point (dp) and also two common ones as seen in the image. To illuminate them, just use a microcontroller to send voltage to the segment that you want to illuminate to compose the character you want.

Usually numbers are always represented, but you can also create some letters, but not all. Y throwing a little imagination also some symbols. This is already a matter of you thinking how. But if you want more complexity, look for LCD displays with more segments like this one.


7 segment display pinout

By example, to make a "7" you can light A, B, and C. Or to make an "A" you can light all but dp and D. Simple, right?

Always check the manufacturer's data sheets or display datasheets that you have bought. There may be variations in some cases.

The only thing you should keep in mind is whether the 7-segment display you have purchased is cathode or common anode. The common cathode has the common pin connected to the negative pins of the LEDs, which means that it is controlled with a logic 1 or high voltage to illuminate the segment. While in the case of the common anode, all the anodes of the LEDs present are connected to the same pin and it is controlled by low voltage or 0. This way you will know if the Arduino microcontroller must send 0 or 1 to activate it ...

Connection with Arduino

7 segment display and Arduino connected

If you have a breadboard, an arduino board, And a 7 segment display to start testing its use, it can be easily connected. You just have to decide to which pin you are going to connect each segment and then remember it to create the appropriate code. In this case, a common cathode 7-segment display has been used, therefore it is activated with 1 or HIGH.

For a common anode there would not be much difference, just change the pin that we have connected to GND to 5v. And remember in the code that it is activated with LOW.

You can do several things, such as directly putting the value of each segment in the code to start doing experiments and see how the display reacts or do something more practical and have it show the output value of a counter, or a value measured by a sensor, etc. In some cases you will need to convert to the decimal system ... A simple code example for a 7 segment display in Arduino IDE would:

// Define the button
#define PUSHBUTTON 10

// It is an array of bits to show different values ​​in the 7 segment display
byte number [10] [8] =
{1, 1, 1, 1, 1, 1, 0, 0}, // 0
{0, 1, 1, 0, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1, 0}, // 2
{1, 1, 1, 1, 0, 0, 1, 0}, // 3
{0, 1, 1, 0, 0, 1, 1, 0}, // 4
{1, 0, 1, 1, 0, 1, 1, 0}, // 5
{1, 0, 1, 1, 1, 1, 1, 0}, // 6
{1, 1, 1, 0, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1, 0}, // 8
{1, 1, 1, 0, 0, 1, 1, 0} // 9

void setup () {
// Start serial monitor
Serial.begin (9600);
for (int i = 2; i <10; i + +)
// Set the pins in output mode
pinMode (i, OUTPUT);

// Configure the pushbutton pin as input

// Set the fixed seed
randomSeed (analogRead (A0));

void loop () {
// Read the value of the button
int value = digitalRead (PUSH BUTTON);

// If it's pressed
if (value == HIGH)

// Generate a random number between 1 and 7
int randomNumber = random (1, 7);

// The segments are put in the correct state to show the random number
for (int e = 0; e <8; e ++)
digitalWrite (e + 2, number [randomNumber] [e]);

delay (500);

7 segment display with multiple digits


For this type of 7 segment display but with multiple digits Everything is the same. The only difference is that we will have to control the digit in which we want to print the character, since it is basically a display with several simple 7-segment displays joined. What manufacturers do is that each display of which it is composed has its own 7 pins for the common segments of all the digits, and the common one (anode or cathode) is particular for each digit.

So can be controlled by Arduino. For example, if you want to activate segment F, you can send LOW or HIGH depending on the type of display it is and that segment will be activated for all the digits present. But only one will light up, the one of the digit that we have activated the common one. That way it is controlled ...

If you are interested in this type of display, No products found. and other specialized stores ...

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *



  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.